#include <cstdio> using namespace std; int n,x,b=0; bool tab[202000]; int main() { scanf("%d",&n); for(int i=0; i<n; i++) { scanf("%d", &x); while(tab[x]) { tab[x]=false; x++; } tab[x]=true; if(x>b) b=x; } printf("%d", b); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> using namespace std; int n,x,b=0; bool tab[202000]; int main() { scanf("%d",&n); for(int i=0; i<n; i++) { scanf("%d", &x); while(tab[x]) { tab[x]=false; x++; } tab[x]=true; if(x>b) b=x; } printf("%d", b); return 0; } |