#include <bits/stdc++.h>
#define debug if(1)
#define VAR(v) #v<<" "<<v<<" "
using namespace std;
int tab[201719];
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin>>n;
for(int i=0; i<n; i++){
int a; cin>>a;
tab[a]++;
}
int res=0;
for(int i=1; i<=201718; i++){
tab[i]+=tab[i-1]/2;
if(tab[i]>0)
res=i;
}
cout<<res;
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 | #include <bits/stdc++.h> #define debug if(1) #define VAR(v) #v<<" "<<v<<" " using namespace std; int tab[201719]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for(int i=0; i<n; i++){ int a; cin>>a; tab[a]++; } int res=0; for(int i=1; i<=201718; i++){ tab[i]+=tab[i-1]/2; if(tab[i]>0) res=i; } cout<<res; return 0; } |
English