Submission #315026

# Submission time Handle Problem Language Result Execution time Memory
315026 2020-10-22T00:47:21 Z daniel920712 CONSUL (info1cup19_consul) C++14
19 / 100
830 ms 2168 KB
#include "grader.h"
#include <map>
using namespace std;
map < int , int > all;
void solve(int n)
{
    int i,t,big;
    for(i=1;i<=n;i++)
    {
        t=kth(i);
        all[t]++;
        big=max(big,all[t]);

        if(all[t]>n/3)
        {
            say_answer(t);
            return;
        }
        if(big+(n-i)<=n/3)
        {
            say_answer(-1);
            return;
        }
    }
    say_answer(-1);
}

Compilation message

consul.cpp: In function 'void solve(int)':
consul.cpp:7:13: warning: 'big' may be used uninitialized in this function [-Wmaybe-uninitialized]
    7 |     int i,t,big;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Correct 38 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 86 ms 504 KB Output is partially correct
2 Partially correct 59 ms 256 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 830 ms 2168 KB Output is partially correct
2 Halted 0 ms 0 KB -