Advertisement
Augenbrauen

skarbonka tłusty prosiak dwójkowy

Nov 20th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main ()
  6. {
  7.     ios_base::sync_with_stdio(0);
  8.     cin.tie(0);
  9.  
  10.     int n;
  11.     cin >> n;
  12.     vector<int> a(n);
  13.     vector<int> powt(201719);
  14.     for (int i = 0; i < n; ++i)
  15.     {
  16.         cin >> a[i];
  17.         ++powt[a[i]];
  18.     }
  19.     for (int i = 0; i < int(powt.size()); ++i)
  20.     {
  21.         if (powt[i] >= 2)
  22.         {
  23.             while (powt[i] >= 2)
  24.             powt[i] -= 2;
  25.             powt[i + 1]++;    
  26.         }
  27.     }
  28.     for (int i = int(powt.size()) - 1; i >= 0; --i)
  29.     {
  30.         if (powt[i] > 0)
  31.         {
  32.             cout << i;
  33.             return 0;
  34.         }
  35.     }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement