#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
constexpr int maxn = 1e5+10, SZ = 50, tot = 50;
mt19937 rng(random_device{}());
int rnd(int x) { return (rng() % x + x) % x; }
int a[maxn], mark[maxn];
void solve(int n)
{
for(int i = 0; 2*i < tot; i++) {
int rd = rnd(n)+1, cor = kth(rd);
if(cnt(cor) > n/3)
return (void)(say_answer(cor));
}
say_answer(-1);
/* vector<int> usar;
map<int,int> freq;
while(usar.size() < min(n, SZ)) {
int rd = rnd(n)+1;
if(!mark[rd])
usar.push_back(rd), a[rd] = kth(rd), freq[a[rd]]++;
mark[rd] = 1;
}
for(int x : usar)
mark[x] = 0;
vector<pair<int,int>> maiores;
for(auto it : freq)
maiores.push_back({it.second, it.first});
sort(maiores.begin(), maiores.end(), greater<pair<int,int>>());
while(maiores.size() > tot - SZ)
maiores.pop_back();
if(n <= SZ) {
if(maiores[0].first > n/3) say_answer(maiores[0].second);
else say_answer(-1);
return;
}
for(int i = 0; i < maiores.size(); i++)
if(cnt(maiores[i].second) > n/3) return (void)(say_answer(maiores[i].first));
say_answer(-1); */
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
200 KB |
Output is correct |
2 |
Correct |
7 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
200 KB |
Output is correct |
2 |
Correct |
18 ms |
200 KB |
Output is correct |
3 |
Correct |
8 ms |
200 KB |
Output is correct |
4 |
Correct |
7 ms |
200 KB |
Output is correct |
5 |
Correct |
20 ms |
200 KB |
Output is correct |
6 |
Correct |
16 ms |
200 KB |
Output is correct |
7 |
Correct |
21 ms |
200 KB |
Output is correct |
8 |
Correct |
24 ms |
200 KB |
Output is correct |
9 |
Correct |
23 ms |
200 KB |
Output is correct |
10 |
Correct |
24 ms |
200 KB |
Output is correct |
11 |
Correct |
22 ms |
200 KB |
Output is correct |
12 |
Correct |
15 ms |
200 KB |
Output is correct |
13 |
Correct |
23 ms |
200 KB |
Output is correct |
14 |
Correct |
21 ms |
200 KB |
Output is correct |