#include <bits/stdc++.h>
using namespace std;
int n , mn,cnt,mx = 1e9,sum,a[500000 + 5];set <int> s;set <int>::iterator it;
int main()
{
cin>>n;
for(int i = 1; i <= n;i ++)
{
cin>>a[i];
}
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 |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Correct |
2 ms |
392 KB |
Output is correct |
4 |
Correct |
2 ms |
452 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
3 ms |
596 KB |
Output is correct |
7 |
Correct |
6 ms |
744 KB |
Output is correct |
8 |
Correct |
49 ms |
1568 KB |
Output is correct |
9 |
Correct |
282 ms |
5304 KB |
Output is correct |
10 |
Incorrect |
128 ms |
5304 KB |
Output isn't correct |