Create 1029.cpp

This commit is contained in:
Kirigaya Kazuto 2016-08-07 12:17:58 +08:00 committed by GitHub
parent 0dcad50d42
commit 3898d24ecd

31
HDOJ/1029.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)==1)
{
int target=(n+1)/2;
int tmp,ans;
map<int,int> p;
for(int i=0;i<n;i++)
{
scanf("%d",&tmp);
p[tmp]++;
}
for(map<int,int>::iterator iter=p.begin();iter!=p.end();iter++)
{
if(iter->second >=target)
{
ans=iter->first;
}
}
printf("%d\n",ans);
}
return 0;
}