#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
void solve(int N) {
srand(time(NULL));
int V[N];
for (int i = 0; i < N; i++) {
V[i] = rand();
}
int ord[N];
iota(ord, ord+N, 0);
sort(ord, ord+N, [&](const int &a, const int &b) {
return V[a] < V[b];
});
map<int, int> m;
for (int x = 0, i = 0; x < min(N, 60) && i < N; x++, i++) {
int v = kth(ord[i]+1);
if (m.find(v) == m.end() && x < min(N, 60)-1) {
m[v] = cnt(v);
x++;
}
if (m[v] > N/3) {
say_answer(v);
return;
}
}
say_answer(-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
208 KB |
Output is correct |
2 |
Correct |
14 ms |
208 KB |
Output is correct |
3 |
Correct |
10 ms |
208 KB |
Output is correct |
4 |
Correct |
10 ms |
208 KB |
Output is correct |
5 |
Correct |
23 ms |
208 KB |
Output is correct |
6 |
Correct |
29 ms |
208 KB |
Output is correct |
7 |
Correct |
24 ms |
208 KB |
Output is correct |
8 |
Correct |
29 ms |
208 KB |
Output is correct |
9 |
Correct |
28 ms |
208 KB |
Output is correct |
10 |
Correct |
29 ms |
208 KB |
Output is correct |
11 |
Correct |
28 ms |
208 KB |
Output is correct |
12 |
Correct |
25 ms |
208 KB |
Output is correct |
13 |
Correct |
32 ms |
208 KB |
Output is correct |
14 |
Correct |
22 ms |
208 KB |
Output is correct |