#include <cstdio> using namespace std; bool A[300005]; int main() { for ( int i=0; i<300000; i++ ) A[i]=0; int n; scanf("%d", &n); while ( n-- ) { int a; scanf("%d",&a); while ( A[a] ) {A[a]=0; a++;} A[a]=1; } int a = 250000; while (a--) { if (A[a]) { printf("%d\n",a); return 0; } } 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 | #include <cstdio> using namespace std; bool A[300005]; int main() { for ( int i=0; i<300000; i++ ) A[i]=0; int n; scanf("%d", &n); while ( n-- ) { int a; scanf("%d",&a); while ( A[a] ) {A[a]=0; a++;} A[a]=1; } int a = 250000; while (a--) { if (A[a]) { printf("%d\n",a); return 0; } } return 0; } |