#include<bits/stdc++.h>
using namespace std;
int N, arr[500005];
int main(){
cin >> N;
for( int i = 1; i <= N; i++ )
cin >> arr[i];
sort( arr+ 1, arr + N + 1 );
for( int i = N; i >= 1; i-- ){
if( arr[i] < N - i + 1 ){
cout << N - i << endl;
return 0;
}
}
cout << N << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
376 KB |
Output is correct |
8 |
Correct |
61 ms |
860 KB |
Output is correct |
9 |
Correct |
320 ms |
2392 KB |
Output is correct |
10 |
Correct |
161 ms |
1272 KB |
Output is correct |