Submission #165707

# Submission time Handle Problem Language Result Execution time Memory
165707 2019-11-28T11:07:01 Z itiam Hindeks (COCI17_hindeks) C++11
25 / 50
1000 ms 5752 KB
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
int L[500005];

int main(){
    int N,x,zb,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;
    }
    for (int i=me-1;i>0;i--){
        zb=0;
        for (int j=i;j<=me;j++){
            zb+=L[j];
        }
        if (zb==i){
            break;
        }
    }
    cout << zb;
    return 0;
}

Compilation message

hindeks.cpp: In function 'int main()':
hindeks.cpp:29:10: warning: 'zb' may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout << zb;
     ~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Correct 2 ms 256 KB Output is correct
6 Incorrect 3 ms 256 KB Output isn't correct
7 Correct 16 ms 376 KB Output is correct
8 Correct 992 ms 1428 KB Output is correct
9 Execution timed out 1068 ms 5752 KB Time limit exceeded
10 Correct 327 ms 2140 KB Output is correct