#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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
248 KB |
Wrong answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
380 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
248 KB |
Wrong answer |
2 |
Halted |
0 ms |
0 KB |
- |