#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 200005
using namespace std;
void solve(){
int n; cin >> n;
int arr[n+1];
int ans=0;
for(int i=1; i<=n; i++) cin >> arr[i];
sort(arr+1, arr+n+1);
for(int i=1; i<=n; i++){
ans = max(ans, min(n-i+1, arr[i]));
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
12 ms |
1116 KB |
Output is correct |
9 |
Correct |
70 ms |
4184 KB |
Output is correct |
10 |
Correct |
30 ms |
2396 KB |
Output is correct |