#include <bits/stdc++.h> using namespace std; int n, t[210000], ans, a; inline void fs(int &x) { register char c = 0; x = 0; while(c < 33) c = getchar_unlocked(); do { x = (x << 1) + (x << 3) + c - '0'; c = getchar_unlocked(); } while(c > 33); } int main() { fs(n); for(int i = 1; i <= n; i++) { fs(a); t[a]++; } for(int i = 1; i <= 202000; i++) { t[i+1] += t[i]/2; if(t[i]) ans = max(ans, i); } cout << ans; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <bits/stdc++.h> using namespace std; int n, t[210000], ans, a; inline void fs(int &x) { register char c = 0; x = 0; while(c < 33) c = getchar_unlocked(); do { x = (x << 1) + (x << 3) + c - '0'; c = getchar_unlocked(); } while(c > 33); } int main() { fs(n); for(int i = 1; i <= n; i++) { fs(a); t[a]++; } for(int i = 1; i <= 202000; i++) { t[i+1] += t[i]/2; if(t[i]) ans = max(ans, i); } cout << ans; } |