做了现在才碰到必须用这名为输入挂的东西。。惭愧额。。
思路:
如果能个数为2的倍数就往上合并,否则就单独拿出来
题是简单题,就是输入不一般。
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
using namespace std;
template <class T>
inline void scand(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 a[10001005];
int main()
{
int n;
scand( n);
int t;
for(int i=1;i<=n;i++)
{
scand( t);
a[t]++;
}
int ans=0;
for(int i=0;i<=1001005;i++)
{
a[i+1]=a[i+1]+a[i]/2;
if(a[i]&1)
ans++;
}
cout<<ans<<endl;
}