//skarbonka.c by Jakub Janaszkiewicz #include <stdio.h> #include <math.h> #define N 201738 int main(void) { int coins [N] = {0}, temp, num; scanf("%d", &num); for(int i = 0; i < num; i++) { scanf("%d", &temp); coins[temp] ++; } for(int i = 0; i < N; ++i) { coins[i+1] += coins[i] / 2; if(coins[i] == 1) temp = i; } printf("%d", temp); 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 | //skarbonka.c by Jakub Janaszkiewicz #include <stdio.h> #include <math.h> #define N 201738 int main(void) { int coins [N] = {0}, temp, num; scanf("%d", &num); for(int i = 0; i < num; i++) { scanf("%d", &temp); coins[temp] ++; } for(int i = 0; i < N; ++i) { coins[i+1] += coins[i] / 2; if(coins[i] == 1) temp = i; } printf("%d", temp); return 0; } |