#include <bits/stdc++.h> #ifdef DEBUG #define D(x) x; #else #define D(x) #endif const int _MAXV = 201739; int N; int p; int m; int ilosc[_MAXV]; int main() { scanf("%d", &N); for(int i = 0; i < N; i++) { scanf("%d", &p); ilosc[p]++; } for(int i = 1; i < _MAXV; i++) { ilosc[i] += ilosc[i - 1] / 2; if(ilosc[i]) m = std::max(i, m); D(printf("I : %d\tILOSC[i] : %d\tM : %d\n", i, ilosc[i], m)); } printf("%d\n", m); 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 <bits/stdc++.h> #ifdef DEBUG #define D(x) x; #else #define D(x) #endif const int _MAXV = 201739; int N; int p; int m; int ilosc[_MAXV]; int main() { scanf("%d", &N); for(int i = 0; i < N; i++) { scanf("%d", &p); ilosc[p]++; } for(int i = 1; i < _MAXV; i++) { ilosc[i] += ilosc[i - 1] / 2; if(ilosc[i]) m = std::max(i, m); D(printf("I : %d\tILOSC[i] : %d\tM : %d\n", i, ilosc[i], m)); } printf("%d\n", m); return 0; } |