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 <bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
void solve(int n)
{
vector<pair<int, int>> v;
map<int, int> mp;
for (int i=1; i<=n; i++) v.push_back({rng(), i});
sort(v.begin(), v.end());
for (int i=1; i<=min(n, 57); i++) mp[kth(v[i-1].second)]++;
priority_queue<pair<int, int>> pq;
for (auto [x, y]:mp) pq.push({y, x});
if (!pq.empty()&&cnt(pq.top().second)>(n/3)) return say_answer(pq.top().second),void();
if (!pq.empty()) pq.pop();
if (!pq.empty()&&cnt(pq.top().second)>(n/3)) return say_answer(pq.top().second),void();
if (!pq.empty()) pq.pop();
if (!pq.empty()&&cnt(pq.top().second)>(n/3)) return say_answer(pq.top().second),void();
if (!pq.empty()) pq.pop();
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... |