#include <bits/stdc++.h> using namespace std; bitset<202000> bs; int ri() { int x; scanf("%d",&x); return x; } void print(int x) { printf("%d",x); } int main() { int r = -1000; deque<int> v; int n = ri(); for(int i=0; i<n; ++i) { int a = ri(); while(bs[a]) { bs[a] = 0; ++a; } bs[a] = 1; r = max(r, a); } print(r); puts(""); return 0; }
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 28 | #include <bits/stdc++.h> using namespace std; bitset<202000> bs; int ri() { int x; scanf("%d",&x); return x; } void print(int x) { printf("%d",x); } int main() { int r = -1000; deque<int> v; int n = ri(); for(int i=0; i<n; ++i) { int a = ri(); while(bs[a]) { bs[a] = 0; ++a; } bs[a] = 1; r = max(r, a); } print(r); puts(""); return 0; } |