| 比赛 | 
    noip2016普及练习2 | 
    评测结果 | 
    AAAAEEEEEA | 
    | 题目名称 | 
    谁是卧底 | 
    最终得分 | 
    50 | 
    | 用户昵称 | 
    Я люблю тебя  | 
    运行时间 | 
    0.665 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    0.28 MiB  | 
    | 提交时间 | 
    2016-11-07 19:57:50 | 
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;
const int maxn=10000+10;
int a[maxn];
int n,m;
bool f=false;
int main()
{
	freopen("leader.in","r",stdin);
	freopen("leader.out","w",stdout);
	
	scanf("%d%d",&n,&m);
	int t;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&t);
		a[t]++;
	}
	m>>=1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>m)
		{
			f=true;
			printf("%d\n",i);
			break;
		}
	}
	if(!f)
	{
		printf("-1\n");
	}
	return 0;
}