#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >>n;
vector <long long> a(n);
for (int i = 0; i < n; ++i) {
cin >>a[i];
}
sort(a.begin(), a.end());
for (int i = n; i >= 0; --i) {
int cnt = (upper_bound(a.begin(), a.end(), i) - a.begin()) - (lower_bound(a.begin(), a.end(), i - 1) - a.begin());
if (cnt >= i) {
cout <<i<<endl;
return 0;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
7 |
Incorrect |
6 ms |
364 KB |
Output isn't correct |
8 |
Incorrect |
47 ms |
1132 KB |
Output isn't correct |
9 |
Incorrect |
257 ms |
4588 KB |
Output isn't correct |
10 |
Incorrect |
112 ms |
2284 KB |
Output isn't correct |