首页 > 其他 > 详细

HDU 1029 Ignatius and the Princess IV

时间:2015-10-06 11:31:55      阅读:172      评论:0      收藏:0      [点我收藏+]

Map水过去了

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

map<int,int>m;
vector<int>b;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        m.clear();
        b.clear();
        for(int i=0;i<n;i++)
        {
            int x;
            scanf("%d",&x);
            if(m[x]==0) b.push_back(x);
            m[x]++;
        }
        for(int i=0;i<b.size();i++)
        {
            if(m[b[i]]>=(n+1)/2)
            {
                printf("%d\n",b[i]);
                break;
            }
        }
    }
    return 0;
}

 

HDU 1029 Ignatius and the Princess IV

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

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