#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; const int N_MAX = 1000000; const int A_MAX = 1000000;//201718; int T[A_MAX + 1]; int main() { int n; scanf("%d", &n); int maks = 0; for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); T[a]++; while (T[a] > 1) { T[a] -= 2; T[a+1]++; a++; } maks = max(maks, a); } printf("%d\n", maks); 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 | #include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; const int N_MAX = 1000000; const int A_MAX = 1000000;//201718; int T[A_MAX + 1]; int main() { int n; scanf("%d", &n); int maks = 0; for (int i = 0; i < n; ++i) { int a; scanf("%d", &a); T[a]++; while (T[a] > 1) { T[a] -= 2; T[a+1]++; a++; } maks = max(maks, a); } printf("%d\n", maks); return 0; } |