#include<iostream>
#include<vector>
using namespace std;
int cnt[];
int main()
{
int time,n,limit;
vector<int> been;
while(cin>>time)
{
int a = ;
memset(cnt,,sizeof(cnt));
limit = (time+)/;
while(time--)
{
cin>>n;
cnt[n]++;
if(cnt[n]>=limit&&a)
{
cout<<n<<endl;
a=;
}
}
}
}
普通cnt数组
DP版本:
include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
_int64 n,a;
while(scanf("%I64d",&n)!=EOF)
{
_int64 b=,c;
while(n--)
{
scanf("%I64d",&a);
if(b==)
{
c=a;
b++;
}
else
{
if(c==a)
b++;
else
b--;
}
}
printf("%I64d\n",c);
}
return ;