#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
int num[60005];
unordered_map<int, int> mp;
void solve(int n)
{
memset(num, -1, sizeof(num));
mt19937 rng(time(NULL));
int q = (n <= 50 ? 50 : 60);
while(q >= 2){
int idx = rng() % n + 1;
if(num[idx] == -1){
q--;
num[idx] = kth(idx);
}
auto u = mp.find(num[idx]);
int cn;
if(u == mp.end()){
cn = cnt(num[idx]);
q--;
}else{
cn = (*u).second;
}
if(cn > n / 3){
say_answer(num[idx]);
return;
}
}
say_answer(-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
456 KB |
Output is correct |
2 |
Correct |
7 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
456 KB |
Output is correct |
2 |
Correct |
24 ms |
460 KB |
Output is correct |
3 |
Correct |
7 ms |
456 KB |
Output is correct |
4 |
Correct |
11 ms |
456 KB |
Output is correct |
5 |
Correct |
24 ms |
456 KB |
Output is correct |
6 |
Correct |
26 ms |
456 KB |
Output is correct |
7 |
Correct |
29 ms |
456 KB |
Output is correct |
8 |
Correct |
26 ms |
456 KB |
Output is correct |
9 |
Correct |
33 ms |
456 KB |
Output is correct |
10 |
Correct |
37 ms |
456 KB |
Output is correct |
11 |
Correct |
34 ms |
456 KB |
Output is correct |
12 |
Correct |
26 ms |
456 KB |
Output is correct |
13 |
Correct |
31 ms |
456 KB |
Output is correct |
14 |
Correct |
25 ms |
456 KB |
Output is correct |