fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using ll = long long;
  5.  
  6. ll setE(vector<int>&a){
  7. map<ll,ll>mp;
  8.  
  9. for(int num : a){
  10. mp[num]++;
  11. }
  12. ll seti = 0;
  13. for(auto it:mp){
  14. ll x = it.first;
  15. ll y = it.second;
  16.  
  17. if(y%2 !=0)seti++;
  18.  
  19. if(y/2 > 0)mp[x+1]+=y/2;
  20. }
  21. return seti;
  22. }
  23. int main() {
  24. int n;
  25. cin>>n;
  26.  
  27. vector<int>a(n);
  28.  
  29. for(int i = 0;i<n ;i++){
  30. cin>>a[i];
  31. }
  32. ll ans = setE(a);
  33. cout<<ans<<endl;
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5320KB
stdin
11
0 0 0 0 0 0 0 0 0 0 0
stdout
3