#include <cstdio> const int MX = 201737 + 7; int G[MX]; int n; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); G[x]++; } for (int i = 0; i < MX - 1; ++i) { G[i + 1] += G[i] / 2; G[i] %= 2; } for (int i = MX - 1; i >= 0; --i) { if (G[i] != 0) { printf("%d\n", i); return 0; } } puts("BARTOSZ KOSTKA"); 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 | #include <cstdio> const int MX = 201737 + 7; int G[MX]; int n; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); G[x]++; } for (int i = 0; i < MX - 1; ++i) { G[i + 1] += G[i] / 2; G[i] %= 2; } for (int i = MX - 1; i >= 0; --i) { if (G[i] != 0) { printf("%d\n", i); return 0; } } puts("BARTOSZ KOSTKA"); return 0; } |