#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
inline void boost(){
ios_base::sync_with_stdio(0);
cin.tie(0);
}
//int dp[int(1e7) + 1];
inline void solve () {
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
boost ();
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i ++) {
cin >> a[i];
}
sort(a, a + n);
int k = 0;
int mini = int(1e9);
for (int i = n - 1; i >= 0; i --) {
k ++;
mini = min(mini, a[i]);
if (mini < k) {
cout << k - 1;
return;
}
}
if (mini >= k) {
cout << k;
return;
}
else {
cout << k - 1;
return;
}
}
int main(){
int kolT = 1;
// cin >> kolT;
while (kolT) {
solve ();
kolT --;
}
exit(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
520 KB |
Output is correct |
4 |
Correct |
2 ms |
520 KB |
Output is correct |
5 |
Correct |
2 ms |
520 KB |
Output is correct |
6 |
Correct |
2 ms |
520 KB |
Output is correct |
7 |
Correct |
4 ms |
520 KB |
Output is correct |
8 |
Correct |
20 ms |
900 KB |
Output is correct |
9 |
Correct |
115 ms |
2564 KB |
Output is correct |
10 |
Correct |
48 ms |
2564 KB |
Output is correct |