#include "grader.h"
#include "bits/stdc++.h"
using namespace std;
mt19937 rng(123);
void solve(int n)
{
map<int, int> mp, us;
int sm = 0;
int c = 0;
while(c < n){
int i = rng() % (n + 1);
c++;
while(us[i] == 1 || i == 0) i = rng() % (n + 1);
us[i] = 1;
int x = kth(i);
mp[x]++;
if(mp[x] == 1){
int k = cnt(x);
sm += k;
if(k > n / 3){
say_answer(x); return;
}
}
if(sm >= (n - n / 3) || c >= n / 3){
say_answer(-1); return;
}
}
say_answer(-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |