#include <iostream>
#include <cstdio>
using namespace std;
long long qread()
{
long long ret=0;
char a=getchar_unlocked();
bool mn=0;
while(a<'0' or a>'9')
{
mn=(a=='-');
a=getchar_unlocked();
}
while(a>='0' && a<='9')
{
ret=(ret<<3)+(ret<<1)+a-'0';
a=getchar_unlocked();
}
if(mn) ret=-ret;
return ret;
}
int ile[2000000];
int main()
{
int n=qread();
for(int i=0; i<n; i++) ile[qread()]++;
int mx=0;
for(int i=0; i<1100000; i++)
{
ile[i+1]+=ile[i]/2;
if(ile[i]>0) mx=max(mx, i);
}
printf("%d", mx);
}
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 32 33 34 35 36 37 38 | #include <iostream> #include <cstdio> using namespace std; long long qread() { long long ret=0; char a=getchar_unlocked(); bool mn=0; while(a<'0' or a>'9') { mn=(a=='-'); a=getchar_unlocked(); } while(a>='0' && a<='9') { ret=(ret<<3)+(ret<<1)+a-'0'; a=getchar_unlocked(); } if(mn) ret=-ret; return ret; } int ile[2000000]; int main() { int n=qread(); for(int i=0; i<n; i++) ile[qread()]++; int mx=0; for(int i=0; i<1100000; i++) { ile[i+1]+=ile[i]/2; if(ile[i]>0) mx=max(mx, i); } printf("%d", mx); } |
English