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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
#include "grader.h"
map<int,int> mp;
bool vis[1005];
void solve(int n){
for(int i=1;i<=n;i++){
vis[i] = false;
}
mp.clear();
srand(314);
if(n<=50){
for(int i=1;i<=n;i++){
mp[kth(i)]++;
}
for(pair<int,int> i:mp){
if(i.second>n/3){
say_answer(i.first);
return;
}
}
say_answer(-1);
return;
}
for(int i=1;i<=50;i++){
int curr = rand()%n+1;
while(vis[curr]){
curr = rand()%n+1;
}
vis[curr] = true;
mp[kth(curr)]++;
}
vector<vector<int>> v;
for(pair<int,int> i:mp){
v.push_back({i.second,i.first});
}
sort(v.begin(),v.end(),greater<vector<int>>());
int vs = v.size();
for(int i=0;i<min(vs,10);i++){
if(cnt(v[i][1])>n/3){
say_answer(v[i][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... |