#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];
}
for (int i = n; i >= 0; --i) {
int cnt = 0;
for (int j = 0; j < n; ++j) {
if (a[j] >= i) {
cnt++;
}
}
if (cnt >= i) {
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 |
276 KB |
Output is correct |
4 |
Correct |
1 ms |
512 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
156 ms |
500 KB |
Output is correct |
8 |
Execution timed out |
1096 ms |
1644 KB |
Time limit exceeded |
9 |
Execution timed out |
1088 ms |
6060 KB |
Time limit exceeded |
10 |
Correct |
84 ms |
3976 KB |
Output is correct |