#include <stdio.h> #define DEF #define #define RI _ri() #define RL _rl() #define RS(x) scanf(" %s",x) #define WI(x) printf("%d\n",x) #define WL(x) printf("%lld\n",x) #define WS(x) puts(x) #define RAI(x,n) FOR(_i,n) x[_i] = RI #define RAL(x,n) FOR(_i,n) x[_i] = RL #define FOR(x,y) for(int x = 0; x < y; x++) static inline int _ri() { int r, i = scanf(" %d",&r); (void)i; return r; } static inline int _rl() { long long r, i = scanf(" %lld",&r); (void)i; return r; } #define N 211718 int t[N]; int main() { int n = RI; FOR (i, n) t[RI]++; int v = 0, max = 0; for (int i = 0; i < N; i++) { v += t[i]; if (v) max = i; v /= 2; } WI(max); 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 | #include <stdio.h> #define DEF #define #define RI _ri() #define RL _rl() #define RS(x) scanf(" %s",x) #define WI(x) printf("%d\n",x) #define WL(x) printf("%lld\n",x) #define WS(x) puts(x) #define RAI(x,n) FOR(_i,n) x[_i] = RI #define RAL(x,n) FOR(_i,n) x[_i] = RL #define FOR(x,y) for(int x = 0; x < y; x++) static inline int _ri() { int r, i = scanf(" %d",&r); (void)i; return r; } static inline int _rl() { long long r, i = scanf(" %lld",&r); (void)i; return r; } #define N 211718 int t[N]; int main() { int n = RI; FOR (i, n) t[RI]++; int v = 0, max = 0; for (int i = 0; i < N; i++) { v += t[i]; if (v) max = i; v /= 2; } WI(max); return 0; } |