51nod 1596 搬货物
来源:互联网 发布:淘宝直播公司 编辑:程序博客网 时间:2024/05/20 06:09
题目链接:
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1596
题解:
论外挂的重要性,强行卡过去。
代码:
#include <map>#include <cmath>#include <vector>#include <queue>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define met(a,b) memset(a,b,sizeof(a))#define inf 0x3f3f3f3fconst int maxn = 1e6+10;vector<int> p1,p2;priority_queue<int,vector<int>,greater<int> >q;map<int,int> mp;int num[maxn];void init(){ mp.clear(); while(!q.empty()) q.pop();}template <class T>inline void scan_d(T &ret){ char c; ret = 0; while ((c = getchar()) < '0' || c > '9'); while (c >= '0' && c <= '9') { ret = ret * 10 + (c - '0'), c = getchar(); }}int main(){ int n; while(scanf("%d",&n)!=EOF) { init(); int x; for(int i=0;i<n;i++) { scan_d(x); if(!mp[x]) q.push(x); mp[x]++; } int cnt=0; while(!q.empty()) { int w=q.top(); q.pop(); int x=mp[w]; int y=x/2; int z=x%2; if(y) { if(!mp[w+1]) q.push(w+1); mp[w+1]+=y; } if(z) cnt++; } printf("%d\n",cnt); }}
阅读全文
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 搬货物
- 51nod 1596 搬货物
- 51nod 1596 搬货物
- 51nod 搬货物
- MNIST的AlexNet实现
- 【bzoj 3132】上帝造题的七分钟(二维树状数组)
- MODBUS协议
- http与socket和https的区别
- ArcGIS10.2安装
- 51nod 1596 搬货物
- EasyUI----界面搭建
- Ros学习笔记(一)
- 数据结构实验之链表九:双向链表
- sql tuning:select锁insert
- wget命令的使用(转载)
- Java动态代理简释
- String的特点一旦被赋值就不能改变图解
- 【bzoj4197】【NOI2015】寿司晚宴