#include <bits/stdc++.h>
#include <map>
#include "grader.h"
using namespace std;
void solve(int n)
{
srand(time(0));
map <int,int> mp;
vector <int> used(n);
set <int> s;
if(n <= 50) {
for(int i = 0; i < n; i ++) {
int val = kth(i+1);
mp[val] ++;
if(mp[val] > n / 3) {
say_answer(val);
return;
}
}
say_answer(-1);
return;
}
for(int i = 0; i < 30; i ++) {
int val = rand() % n;
int k = kth(val+1);
if(cnt(k) > n/3) {
say_answer(k);
return;
}
mp[k] ++;
}
say_answer(-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
200 KB |
Output is correct |
2 |
Correct |
7 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
200 KB |
Output is correct |
2 |
Correct |
25 ms |
200 KB |
Output is correct |
3 |
Correct |
8 ms |
200 KB |
Output is correct |
4 |
Correct |
8 ms |
200 KB |
Output is correct |
5 |
Correct |
24 ms |
200 KB |
Output is correct |
6 |
Correct |
25 ms |
200 KB |
Output is correct |
7 |
Correct |
22 ms |
200 KB |
Output is correct |
8 |
Correct |
28 ms |
200 KB |
Output is correct |
9 |
Correct |
22 ms |
200 KB |
Output is correct |
10 |
Correct |
27 ms |
292 KB |
Output is correct |
11 |
Correct |
28 ms |
200 KB |
Output is correct |
12 |
Correct |
22 ms |
200 KB |
Output is correct |
13 |
Correct |
23 ms |
200 KB |
Output is correct |
14 |
Correct |
25 ms |
200 KB |
Output is correct |