#include <iostream>
using namespace std;
int n, i, x, f[500002], v[500002];
int main(){
cin>>n;
for(i=1; i<=n; i++){
cin>>x;
if(x>n){
x=n;
}
f[x]++;
}
for(i=n; i>=1; i--){
f[i]+=f[i+1];
if(f[i]>=i){
cout<<i;
return 0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
7 ms |
376 KB |
Output is correct |
8 |
Correct |
53 ms |
1252 KB |
Output is correct |
9 |
Correct |
293 ms |
5752 KB |
Output is correct |
10 |
Correct |
144 ms |
2040 KB |
Output is correct |