#include <cstdio> int t[202000]; int main() { int a,s,d=0,z; scanf("%d", &a); for (int i=0; i<a; i++) { scanf("%d", &s); t[s]++; if (s>d) d=s; } z=0; s=0; while(s<d || z>1) { s++; z/=2; if (s<202000) z+=t[s]; } printf("%d", s); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <cstdio> int t[202000]; int main() { int a,s,d=0,z; scanf("%d", &a); for (int i=0; i<a; i++) { scanf("%d", &s); t[s]++; if (s>d) d=s; } z=0; s=0; while(s<d || z>1) { s++; z/=2; if (s<202000) z+=t[s]; } printf("%d", s); } |