fork(9) download
  1. #include <iostream>
  2. using namespace std;
  3. const int MAX = 1000100;
  4. int a[MAX];
  5. int main()
  6. {
  7. ios::sync_with_stdio(false);
  8. int n;
  9. cin >> n;
  10. for (int i = 0; i < n; i++)
  11. {
  12. int x;
  13. cin >> x;
  14. a[x]++;
  15. }
  16. int ans = 0;
  17. for (int i = 0; i < MAX - 1; i++)
  18. {
  19. a[i + 1] += a[i] / 2;
  20. a[i] %= 2;
  21. ans += a[i];
  22. }
  23. cout << ans << endl;
  24. return 0;
  25. }
  26.  
Runtime error #stdin #stdout 0s 7360KB
stdin
Standard input is empty
stdout
Standard output is empty