#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ford(a,b,c) for(int a = b; a <= c; a++)
#define fti(a,b,c) for(int a = b; a >= c; a--)
#define file(name) freopen(name ".inp", "r", stdin); freopen(name ".out", "w", stdout);
#define siz size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define timestart clock_t begin = clock();
#define timeend clock_t end = clock();
#define couttime cout << "\n" << (long double)(end - begin) / CLOCKS_PER_SEC << "s" << "\n";
#define ll long long
#define ms(a,b) memset(a,b,sizeof(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define fi first
#define se second
using namespace std;
int n,c[500001];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n;
ford(i,1,n) cin >> c[i];
sort(c+1,c+n+1,greater<int>());
int cnt=0;
ford(i,1,n) {
if(c[i]>cnt&&cnt<=i) {
cnt++;
}
else {
break;
}
}
cout << cnt;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |