#include <bits/stdc++.h>
#define fora(i,a,b) for ( ll i = a ; i <= b ; i++ )
#define ptrongnopro cin.tie(nullptr)->ios_base::sync_with_stdio(0); cout.tie(0);
using namespace std;
typedef long long ll;
ll n;
ll dem=0;
vector<ll> v;
int main(){
ptrongnopro
cin >> n;
for ( ll i = 1 ; i <= n ; i++ ){
ll x; cin >> x; v.push_back(x);
}
sort( v.begin() , v.end() );
for ( ll i = n-1 ; i >= 0 ; i-- ){
if ( v[i] >= n-i ) dem++;
}
if ( dem == 0 ) cout << v[0];
else cout << dem;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
856 KB |
Output is correct |
8 |
Correct |
13 ms |
2012 KB |
Output is correct |
9 |
Correct |
72 ms |
7752 KB |
Output is correct |
10 |
Correct |
32 ms |
4044 KB |
Output is correct |