#include "bits/stdc++.h"
using namespace std;
#define intt long long
#define fi first
#define se second
#define endl "\n"
const intt mxN = 2e5+67;
const intt LG = 31;
const intt inf = 1e18;
const intt mod = 1e9 + 7;
void smile() {
intt n;
cin >> n;
vector<intt> a(n);
multiset<intt> mst;
for(intt i = 0; i < n; i++) {
cin >> a[i];
mst.insert(a[i]);
}
intt h = 0;
for(intt i = 1; i <= *(--mst.end()); i++) {
while(not mst.empty() && *mst.begin() < i) {
mst.erase(mst.begin());
}
if(mst.size() >= i) {
h = i;
} else{
break;
}
}
cout << h << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// freopen("island.in", "r", stdin);
// freopen("island.out", "w", stdout);
intt t = 1, buu = 1;
// cin >> t;
while(t--){
// cout << "Case #" << buu++ << ": ";
smile();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |