首页 > 其他 > 详细

PAT (Advanced Level) 1054. The Dominant Color (20)

时间:2016-05-31 20:39:42      阅读:173      评论:0      收藏:0      [点我收藏+]

简单题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

int a[500000];
int n,m;

int main()
{
  scanf("%d%d",&n,&m);
  for(int i=0;i<n*m;i++) scanf("%d",&a[i]);
  sort(a,a+n*m); a[n*m]=774388357;
  
  
  int num=1;
  for(int i=1;i<=n*m;i++)
  {
    if(a[i]==a[i-1]) num++;
    else 
    {
      if(num>n*m/2) 
      {
        printf("%d\n",a[i-1]);
        break;
      }
      else num=1;
    }
  }  
    return 0;
}

 

PAT (Advanced Level) 1054. The Dominant Color (20)

原文:http://www.cnblogs.com/zufezzt/p/5546956.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!