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
#include <cstdio>
#define MAXS 2201719

int main(void){
    unsigned int n, i, tmp, *nomin, maxnomin;
    nomin = new unsigned int[MAXS];
    /* Wczytanie */
    scanf("%u", &n);
    for(i = 0; i < MAXS; i++) nomin[i] = 0;
    for(i = 0; i < n; i++){
        scanf("%u", &tmp);
        nomin[tmp]++;
    }

    maxnomin = nomin[0];
    for(i = 0; i < MAXS - 1; i++){
        if(nomin[i]){
            nomin[i+1] += (nomin[i]/2);
            maxnomin = i;
        }
    }
    printf("%u", maxnomin);
    delete nomin;
    return 0;
}