# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206709 | mayhoubsaleh | CONSUL (info1cup19_consul) | C++14 | 0 ms | 0 KiB |
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;
void solve(int n)
{
bool vis[1010];
memset(vis,0,sizeof vis);
int x=min(n-1,59);
map<int,int>res;
while(x--){
int id=rand()%n+1;
if(vis[id])}{x++;continue;}
vis[id]=1;
int val=kth(id);
res[val]++;
if(res[val]>n/3){
say_answer(val);
return;
}
}
pair<int,int>mx={-1,-1};
for(auto x:res){
if(x.second>mx.second){
mx=x;
}
}
if(cnt(mx.first)>n/3){
say_answer(mx.second);
return ;
}
say_answer(-1);
}