/*
wynik = najstarszy bit sumy potęg dwójki
limity:
0<=a<=201718<2^18
1<=n<=1e6<2^20
*/
#include <stdio.h>
#include <string.h>
char s[201800];
int main()
{
int n, a, x=0;
bzero(s, sizeof(s));
scanf("%d", &n);
while (n--)
{
scanf("%d", &a);
while (s[a] == 1) s[a++] = 0;
s[a] = 1;
if (x<a) x = a;
}
printf("%d\n", x);
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 | /* wynik = najstarszy bit sumy potęg dwójki limity: 0<=a<=201718<2^18 1<=n<=1e6<2^20 */ #include <stdio.h> #include <string.h> char s[201800]; int main() { int n, a, x=0; bzero(s, sizeof(s)); scanf("%d", &n); while (n--) { scanf("%d", &a); while (s[a] == 1) s[a++] = 0; s[a] = 1; if (x<a) x = a; } printf("%d\n", x); return 0; } |
English