Submission #292463

# Submission time Handle Problem Language Result Execution time Memory
292463 2020-09-07T05:03:46 Z 7_7_7 Hindeks (COCI17_hindeks) C++17
50 / 50
115 ms 5624 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int res = 0;
    for(int i = 1; i <= n; i ++){
        int l = 0, r = i;
        while(l < r){
            int m = (l + r) / 2;
            if((a[i - m] >= (m + 1))) l = m + 1;
            else r = m;
        }
        res = max(res, l);
    }
    cout << res << "\n";
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 23 ms 1280 KB Output is correct
9 Correct 115 ms 5624 KB Output is correct
10 Correct 57 ms 3064 KB Output is correct