#include <bits/stdc++.h> #include <unistd.h> #define inf 1000000007LL #define INF 1000000000000000007LL #define mp make_pair #define pb push_back #define eb emplace_back #define st first #define nd second #define ll long long #define ld long double #define pii pair<int,int> #define vi vector<int> #define vll vector<long long> #define vpii vector< pair<int,int> > #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define LOG(x) (63-__builtin_clzll(x)) #define rep(i, n) for(int i=0; i<(n); ++i) #define rep1(i, n) for(int i=1; i<=(n); ++i) #define endr cerr<<'\n' #define endl '\n' #ifdef DEBUG #define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__) #define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';} #define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';} #define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';} #define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';} #define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';} #else #define cerr if(0)cout #define pv(...) if(0)endr #define ps(x) if(0)endr #define pa(x, xs) if(0)endr #define pal(x, xs) if(0)endr #define ppii(x, xs) if(0)endr #define pm(x, xn, xm) if(0)endr #endif using namespace std; template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);} template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;} const int N = 1000007; int n, cnt[N]; void solve() { cin>>n; for (int i=1; i<=n; ++i) { int x; cin>>x; ++cnt[x]; } for (int i=0; i<N/2; ++i) { cnt[i+1] += cnt[i]/2; } for (int i=N/2; i>=0; --i) { if (cnt[i] > 0) cout<<i, exit(0); } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout<<fixed<<setprecision(10); solve(); 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #include <bits/stdc++.h> #include <unistd.h> #define inf 1000000007LL #define INF 1000000000000000007LL #define mp make_pair #define pb push_back #define eb emplace_back #define st first #define nd second #define ll long long #define ld long double #define pii pair<int,int> #define vi vector<int> #define vll vector<long long> #define vpii vector< pair<int,int> > #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define LOG(x) (63-__builtin_clzll(x)) #define rep(i, n) for(int i=0; i<(n); ++i) #define rep1(i, n) for(int i=1; i<=(n); ++i) #define endr cerr<<'\n' #define endl '\n' #ifdef DEBUG #define pv(...) cerr<<'\n',dbg(#__VA_ARGS__, __VA_ARGS__) #define ps(x) {cerr<<'\n'<<#x<<":\n:";for(auto q:(x)){cerr<<q<<" ";}cerr<<'\n';} #define pa(x, xs) {cerr<<'\n'<<#x<<":\n:";for(int q=0; q<=(xs); ++q){cerr<<x[q]<<" ";}cerr<<'\n';} #define pal(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 3-(int32_t)log10(q):3)<<x[q]<<'\n';}cerr<<'\n';} #define ppii(x, xs) {cerr<<'\n'<<#x<<":\n";for(int q=0; q<=(xs); ++q){cerr<<q<<": "<<setw(q? 6-(int32_t)log10(q):6)<<x[q].first<<" "<<setw(5)<<x[q].second<<'\n';}cerr<<'\n';} #define pm(x, xn, xm) {cerr<<'\n'<<#x<<":\n";for(int qa=0; qa<=(xn); ++qa){for(int qb=0; qb<=(xm); ++qb){cerr<<setw(6)<<x[qa][qb]<<" ";}cerr<<'\n';}cerr<<'\n';} #else #define cerr if(0)cout #define pv(...) if(0)endr #define ps(x) if(0)endr #define pa(x, xs) if(0)endr #define pal(x, xs) if(0)endr #define ppii(x, xs) if(0)endr #define pm(x, xn, xm) if(0)endr #endif using namespace std; template<class T> void dbg(const char* xn, T x){cerr<<xn<<": "<<x<<"\n";} template<class T, class... TA> void dbg(const char* xn, T x, TA... t){while(*xn!=',')cerr<<*xn++;cerr<<": "<<x<<",";dbg(xn+1, t...);} template<class T> inline bool upd_max(T &x, T y){return y>x?x=y,true:false;} template<class T> inline bool upd_min(T &x, T y){return y<x?x=y,true:false;} const int N = 1000007; int n, cnt[N]; void solve() { cin>>n; for (int i=1; i<=n; ++i) { int x; cin>>x; ++cnt[x]; } for (int i=0; i<N/2; ++i) { cnt[i+1] += cnt[i]/2; } for (int i=N/2; i>=0; --i) { if (cnt[i] > 0) cout<<i, exit(0); } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout<<fixed<<setprecision(10); solve(); return 0; } |