mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1029.cpp
This commit is contained in:
parent
0dcad50d42
commit
3898d24ecd
31
HDOJ/1029.cpp
Normal file
31
HDOJ/1029.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user