#include <iostream>
#include <vector>
#include<stdint.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
vector<int> v(203000,0);
int n,a,o=0;
cin >> n;
for(int i=0; i<n; i++){
cin >> a;
while(v[a]==1){
v[a]=0; a++;
}
v[a]=1;
if(a>o){o=a;}
}
cout<<o<<'\n';
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 | #include <iostream> #include <vector> #include<stdint.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); vector<int> v(203000,0); int n,a,o=0; cin >> n; for(int i=0; i<n; i++){ cin >> a; while(v[a]==1){ v[a]=0; a++; } v[a]=1; if(a>o){o=a;} } cout<<o<<'\n'; return 0; } |
English