HDU 5364 Distribution money(water)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5364

#include<bits/stdc++.h>
using namespace std;

#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long

#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
const int  maxn =1e4+5;
const int mod=9999991;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int n,a;
int cnt[maxn],ans;

int main()
{
    while(scanf("%d",&n)!=EOF){
        mst(cnt,0),ans=-1;
        for(int i=1;i<=n;i++){
            scanf("%d",&a);
            if(++cnt[a]>=n/2+1) ans=a;
        }
        printf("%d\n",ans);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_37451344/article/details/84075392
今日推荐