#include <iostream> using namespace std; int t[1000009]; int main(){ ios::sync_with_stdio(0); int n; cin>>n; for(int i=0; i<n; i++){ int x; cin>>x; do{ t[x]++; if(t[x]==2){ t[x]=0; x++; } else x=-1; }while(x!=-1); } int wyn=0; for(int i=0; i<1000009; i++){ if(t[i]==1) wyn=max(wyn, i); } cout<<wyn<<"\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> using namespace std; int t[1000009]; int main(){ ios::sync_with_stdio(0); int n; cin>>n; for(int i=0; i<n; i++){ int x; cin>>x; do{ t[x]++; if(t[x]==2){ t[x]=0; x++; } else x=-1; }while(x!=-1); } int wyn=0; for(int i=0; i<1000009; i++){ if(t[i]==1) wyn=max(wyn, i); } cout<<wyn<<"\n"; return 0; } |