This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "grader.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <map>
typedef long long llong;
const int MAXN = 1000 + 10;
const int INF = 1e9;
std::map <int,int> map;
bool used[MAXN];
void solve(int n)
{
if (n <= 50)
{
for (int i = 1 ; i <= n ; ++i)
{
map[kth(i)]++;
}
for (auto [key, value] : map)
{
if (value > n/3)
{
say_answer(key);
return;
}
}
say_answer(-1);
return;
}
srand(69);
std::fill(used + 1, used + 1 + n, false);
for (int i = 1 ; i <= std::min(n/2, 30) ; ++i)
{
int curr;
do
{
curr = rand()%n + 1;
} while (used[curr]);
used[curr] = true;
curr = kth(curr);
if (cnt(curr) > n/3)
{
say_answer(curr);
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... |