HDU 1029 Ignatius and the Princess IV

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
",b[i]);
                break;
            }
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/4856863.html