搬货物
来源:互联网 发布:汽车内饰件图解知乎 编辑:程序博客网 时间:2024/06/10 08:18
现在有n个货物,第i个货物的重量是
样例解释:
1,1,2作为一组。
3,3作为一组。
Input
单组测试数据。第一行有一个整数n (1≤n≤10^6),表示有几个货物。第二行有n个整数 w1,w2,...,wn,(0≤wi≤10^6)。
Output
输出最少的运货次数。
Input示例
样例输入151 1 2 3 3
Output示例
样例输出12
#include <stdio.h>#include <string.h>#include <math.h>const int SIZE = 1e6 + 50;int buf[SIZE];int main(int argc, const char * argv[]){int n;scanf("%d", &n);memset(buf, 0, sizeof(buf)); int a;for (int i = 0; i < n; i++){scanf("%d", &a);buf[a]++;}int result = 0;for (int i = 0; i < SIZE; i++){buf[i+1] += (buf[i] >> 1);result += (buf[i]&1);}printf("%d\n", result);return 0;}
阅读全文
0 0
- 搬货物
- 51nod 搬货物
- 1596 搬货物
- 51NOD 1596 搬货物
- 51Nod-1596-搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51Nod 1596 搬货物
- 51nod-1596 搬货物
- 51Nod 1596 搬货物
- 51nod-1596 搬货物
- 51nod 1596 搬货物
- 51Nod 1596 搬货物
- 51nod 1596 搬货物
- 51Nod 1596 搬货物
- 51nod 1596 搬货物
- 51Nod1596 搬货物(codeforces)
- linux和window 双系统文件修改
- python 基础脚本练习
- MacOS上添加到某网络的路由
- Android--Android6.0版的Notification配置
- 利用NextCloud配置私有云
- 搬货物
- python练习1
- 找了很久的低功耗蓝牙程序开发,终于在国外找到了部分资料
- javascript的数据类型与复制模式
- VMware Player安装Ubuntu12.04后黑屏的问题
- dedecms列表标签重点归纳
- 51Nod-1456-小K的技术
- bzoj 1024: [SCOI2009]生日快乐
- Python 中的字符串 & 字节和字节数组 (7)