#include <algorithm>
#include<cstdio>
using namespace std;
int main()
{
int temp,n,mx=0;
scanf("%d",&n);
bool a[202000]={0};
for(int i=0;i<n;i++){
scanf("%d",&temp);
while(a[temp]){
a[temp]=0;
temp++;
}
a[temp]=1;
mx=max(temp,mx);
}
printf("%d",mx);
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <algorithm> #include<cstdio> using namespace std; int main() { int temp,n,mx=0; scanf("%d",&n); bool a[202000]={0}; for(int i=0;i<n;i++){ scanf("%d",&temp); while(a[temp]){ a[temp]=0; temp++; } a[temp]=1; mx=max(temp,mx); } printf("%d",mx); return 0; } |
English