#include <cstdio> #include <cstring> typedef unsigned I; static const I SIZE = 201718 + 1; static I tab[SIZE]; static I calc() { I ret = 0; I val = 0; for (I i=0; i<SIZE; ++i) { val = val / 2 + tab[i]; if (val) ret = i; } while (val) { val /= 2; if (val) ++ret; } return ret; } int main() { I n, a; scanf("%u\n", &n); memset(tab, 0, sizeof(tab)); for (I i=0; i<n; ++i) { scanf("%u\n", &a); ++tab[a]; } printf("%u\n", calc()); 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 29 30 31 32 33 34 | #include <cstdio> #include <cstring> typedef unsigned I; static const I SIZE = 201718 + 1; static I tab[SIZE]; static I calc() { I ret = 0; I val = 0; for (I i=0; i<SIZE; ++i) { val = val / 2 + tab[i]; if (val) ret = i; } while (val) { val /= 2; if (val) ++ret; } return ret; } int main() { I n, a; scanf("%u\n", &n); memset(tab, 0, sizeof(tab)); for (I i=0; i<n; ++i) { scanf("%u\n", &a); ++tab[a]; } printf("%u\n", calc()); return 0; } |