Submission #498949

#TimeUsernameProblemLanguageResultExecution timeMemory
498949cadmiumskyCONSUL (info1cup19_consul)C++14
100 / 100
38 ms200 KiB
#include <random> #include <unordered_map> #include <chrono> #include "grader.h" using namespace std; mt19937 rng(time(0)); void solve(int N) { if(N<=50) { unordered_map<int,int> freq; for(int i=1,x; i<=N; i++) { freq[x = kth(i)]; freq[x]++; } for(auto x:freq) { if(x.second > N/3) { say_answer(x.first); return; } } say_answer(-1); return; } for(int i=0; i<30; i++) { int index=(rng()%N)+1; int val=kth(index); int freq=cnt(val); if(freq > N/3) { say_answer(val); return; } } say_answer(-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...