답안 #856058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
856058 2023-10-02T16:06:48 Z vjudge1 Hindeks (COCI17_hindeks) C++17
50 / 50
39 ms 15444 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define all(x) x.begin()+1,x.end()
const int N = 4e5+1;


void solve() {
	int n;
	cin >> n;
	vi a(n+1),mp(1000001,0);
	F(i,n) cin >> a[i];
	F(i,n) mp[a[i]]++;
	for (int i=1000000-1;i>=1;i--) mp[i]+=mp[i+1];
	int ans = 0;
	for (int i=1;i<=1000000;i++) if (mp[i] >= i) ans = i;
	cout << ans << endl;
}     	
                 
                 
                 
                 
                 
                 
                 
                 
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}

# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8284 KB Output is correct
2 Correct 5 ms 8284 KB Output is correct
3 Correct 4 ms 8284 KB Output is correct
4 Correct 5 ms 8284 KB Output is correct
5 Correct 4 ms 8280 KB Output is correct
6 Correct 5 ms 8440 KB Output is correct
7 Correct 5 ms 8284 KB Output is correct
8 Correct 12 ms 9672 KB Output is correct
9 Correct 39 ms 15444 KB Output is correct
10 Correct 21 ms 11864 KB Output is correct