#include <bits/stdc++.h>
using namespace std;
const int SIZE = 250000;
int t[SIZE];
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >>n;
int m = -2e9;
for(int i=0; i<n; i++){
int x;
cin >>x;
m = max(m,x);
t[x]++;
}
int ile = 0;
for(int i=1; i<=m; i++){
ile = (ile + t[i])/2;
}
while(ile > 0){
ile /= 2;
m++;
}
cout<<m<<"\n";
}
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> using namespace std; const int SIZE = 250000; int t[SIZE]; int main(){ ios_base::sync_with_stdio(false); int n; cin >>n; int m = -2e9; for(int i=0; i<n; i++){ int x; cin >>x; m = max(m,x); t[x]++; } int ile = 0; for(int i=1; i<=m; i++){ ile = (ile + t[i])/2; } while(ile > 0){ ile /= 2; m++; } cout<<m<<"\n"; } |
English