Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main ()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int n;
- cin >> n;
- vector<int> a(n);
- vector<int> powt(201719);
- for (int i = 0; i < n; ++i)
- {
- cin >> a[i];
- ++powt[a[i]];
- }
- for (int i = 0; i < int(powt.size()); ++i)
- {
- if (powt[i] >= 2)
- {
- while (powt[i] >= 2)
- powt[i] -= 2;
- powt[i + 1]++;
- }
- }
- for (int i = int(powt.size()) - 1; i >= 0; --i)
- {
- if (powt[i] > 0)
- {
- cout << i;
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement