#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()) + 1;
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 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Incorrect |
0 ms |
364 KB |
Output isn't 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 |
5 ms |
364 KB |
Output isn't correct |
8 |
Incorrect |
47 ms |
1132 KB |
Output isn't correct |
9 |
Incorrect |
261 ms |
4332 KB |
Output isn't correct |
10 |
Incorrect |
123 ms |
2284 KB |
Output isn't correct |