hdu 5364 Distribution money
#include<stdio.h>
#include<string.h>
#include<string>
#include<stack>
#include<algorithm>
using namespace std;
struct node
{
int num;
int cnt;
}a[10000+5];
bool cmp(node n1,node n2)
{
return n1.cnt>n2.cnt;
}
int main()
{
int n,i,t;
while(~scanf("%d",&n))
{
for(i=0;i<=10000;i++)
{
a[i].num=i;
a[i].cnt=0;
}
for(i=0;i<n;i++)
{
scanf("%d",&t);
a[t].cnt++;
}
sort(a,a+10005,cmp);
if(2*a[0].cnt>n) printf("%d\n",a[0].num);
else
printf("-1\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/