답안 #1108482

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108482 2024-11-04T08:39:24 Z toast12 Hindeks (COCI17_hindeks) C++14
50 / 50
92 ms 4344 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXA = 1e6;

int main() {
    int n;
    cin >> n;
    vector<int> freq(MAXA+1);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        freq[x]++;
    }
    int cur = 0;
    for (int i = MAXA; i >= 0; i--) {
        if (cur+freq[i] >= i) {
            cout << i << '\n';
            return 0;
        }
        cur += freq[i];
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4176 KB Output is correct
2 Correct 2 ms 4176 KB Output is correct
3 Correct 3 ms 4344 KB Output is correct
4 Correct 3 ms 4176 KB Output is correct
5 Correct 3 ms 4176 KB Output is correct
6 Correct 3 ms 4344 KB Output is correct
7 Correct 4 ms 4176 KB Output is correct
8 Correct 21 ms 4176 KB Output is correct
9 Correct 92 ms 4176 KB Output is correct
10 Correct 46 ms 4176 KB Output is correct