比赛 |
noip2016普及练习2 |
评测结果 |
AAAAAAAAAA |
题目名称 |
谁是卧底 |
最终得分 |
100 |
用户昵称 |
蜗牛哲 |
运行时间 |
0.041 s |
代码语言 |
C++ |
内存使用 |
0.28 MiB |
提交时间 |
2016-11-07 19:51:19 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<cstdlib>
#include<ctime>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<sstream>
#include<iomanip>
#define mint map<int,int>::iterator
using namespace std;
//=====================struct declaration======================
//=====================var declarartion========================
map<int,int> a;
int n,m;
//=====================function declaration====================
int getint();
//=====================main code===============================
int main()
{
freopen("leader.in","r",stdin);
freopen("leader.out","w",stdout);
n=getint(); m=getint();
for(int ii=1; ii<=m; ii++)
{
int x;
x=getint();
a[x]++;
}
for(mint it=a.begin(); it!=a.end(); it++)
{
if(it->second>m/2)
{
printf("%d\n",*it);
return 0;
}
}
printf("-1\n");
return 0;
}
//=====================function code===========================
int getint()
{
int x=0,s=1;
char ch=' ';
while(ch<'0' || ch>'9')
{
ch=getchar();
if(ch=='-') s=-1;
}
while(ch>='0' && ch<='9')
{
x=x*10+ch-'0';
ch=getchar();
}
return x*s;
}