#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 = 0;
int l = -1, r = n;
while (r - l > 1) {
int m = (r + l) / 2;
if (a[m] >= i) {
r = m;
}
else {
l = m;
}
}
if (cnt >= l) {
cout <<i<<endl;
return 0;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is 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 |
5 ms |
364 KB |
Output isn't correct |
8 |
Incorrect |
53 ms |
1132 KB |
Output isn't correct |
9 |
Incorrect |
254 ms |
4204 KB |
Output isn't correct |
10 |
Correct |
103 ms |
2284 KB |
Output is correct |