#include <bits/stdc++.h>
using namespace std;
long long n , mn ,cnt,mx = 1e7,sum,a[500000 + 5];
int main()
{
cin>>n;
for(int i = 1; i <= n ;i ++)
{
cin>>a[i];
}mn = n;
sort(a + 1, a + n + 1);
for(int i = 1; i <= n ;i ++)
{
cnt++;
if(n - cnt >= a[i])
{
mn = n - cnt;
}
}
cout<<mn;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
432 KB |
Output is correct |
3 |
Correct |
3 ms |
440 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
508 KB |
Output is correct |
6 |
Correct |
3 ms |
508 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
48 ms |
1280 KB |
Output is correct |
9 |
Correct |
231 ms |
4412 KB |
Output is correct |
10 |
Correct |
124 ms |
4412 KB |
Output is correct |