#include <stdio.h> int main (){ int n, i, suma[221213]={}, x, m; scanf("%d", &n); for(i = 0; i < n; i++){ scanf("%d", &x); suma[x]++; } m = 0; for(i=0;i<212345;++i) if(suma[i]>0){ m=i; suma[i+1]+=suma[i]/2; suma[i]=suma[i]%2; } printf("%d", m); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <stdio.h> int main (){ int n, i, suma[221213]={}, x, m; scanf("%d", &n); for(i = 0; i < n; i++){ scanf("%d", &x); suma[x]++; } m = 0; for(i=0;i<212345;++i) if(suma[i]>0){ m=i; suma[i+1]+=suma[i]/2; suma[i]=suma[i]%2; } printf("%d", m); return 0; } |