hdu-1029 Ignatius and the Princess IV

#include<stdio.h>
int a[1000010]={0};
int main()
{
   int n,m,i,k;
   while(~scanf("%d",&n))
   {
     for(i=1;i<=n;i++)
  {
   scanf("%d",&m);
     a[m]++;
  if(a[m]>=(n+1)/2)
   k=m;
  }
    printf("%d\n",k);
   }
  return 0;
}                            //方法比我的好,我的提交的时候超时了,看到这个方法时眼前一亮,还是自己知道的少啊

你可能感兴趣的:(hdu-1029 Ignatius and the Princess IV)