#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 = 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 |
Incorrect |
16 ms |
456 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
456 KB |
Output is correct |
2 |
Correct |
12 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
456 KB |
Output is correct |
2 |
Correct |
15 ms |
456 KB |
Output is correct |
3 |
Correct |
5 ms |
456 KB |
Output is correct |
4 |
Correct |
12 ms |
456 KB |
Output is correct |
5 |
Correct |
22 ms |
456 KB |
Output is correct |
6 |
Correct |
15 ms |
456 KB |
Output is correct |
7 |
Correct |
32 ms |
456 KB |
Output is correct |
8 |
Correct |
24 ms |
456 KB |
Output is correct |
9 |
Correct |
30 ms |
456 KB |
Output is correct |
10 |
Correct |
28 ms |
456 KB |
Output is correct |
11 |
Correct |
17 ms |
456 KB |
Output is correct |
12 |
Correct |
14 ms |
456 KB |
Output is correct |
13 |
Correct |
37 ms |
456 KB |
Output is correct |
14 |
Correct |
15 ms |
456 KB |
Output is correct |