Submission #165714

# Submission time Handle Problem Language Result Execution time Memory
165714 2019-11-28T11:22:04 Z itiam Hindeks (COCI17_hindeks) C++11
45 / 50
1000 ms 2296 KB
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
int L[500005];

int main(){
    int N,x,zb=0,me=0;
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> x;
        if (x<=500000)  L[x]+=1;
        else    L[500000+1]+=1;
        if (x>me)   me=x;
    }
    if (me>=500000){
        me=500001;
    }
    /*cout << "L: ";
    for (int i=0;i<=me;i++)  cout << L[i] << " ";
    cout << "\n";
    */
    for (int i=me;i>=0;i--){
        zb=0;
        for (int j=i;j<=me;j++){
            zb+=L[j];
        }
        //cout << "zb: " << zb << "\n";
        if (zb>=i){
            zb=i;
            break;
        }
    }
    cout << zb;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 16 ms 376 KB Output is correct
8 Correct 989 ms 888 KB Output is correct
9 Execution timed out 1067 ms 2296 KB Time limit exceeded
10 Correct 320 ms 504 KB Output is correct