首页 > 其他分享 >HDU 5364

HDU 5364

时间:2023-08-15 17:32:20浏览次数:45  
标签:HDU 5364 temp int money punished ans Output


Distribution money

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 310    Accepted Submission(s): 186

Problem Description
AFA want to distribution her money to somebody.She divide her money into n same parts.One who want to get the money can get more than one part.But if one man's money is more than the sum of all others'.He shoule be punished.Each one who get a part of money would write down his ID on that part.
 
Input
There are multiply cases.
For each case,there is a single integer n(1<=n<=1000) in first line.
In second line,there are n integer a1,a2...an(0<=ai<10000)ai is the the ith man's ID.
 
Output
Output ID of the man who should be punished.
If nobody should be punished,output -1.
 
Sample Input
3
1 1 2
4
2 1 4 3
 
Sample Output
1

-1


#include <stdio.h>
#include <string.h>


int a[1010];
int b[10010];

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int c,temp=0;
        int ans=0;
        memset(b,0,sizeof(b));
        for(int i=0;i<n;i++)
        {
            scanf("%d",&c);
            b[c]++;
            if(b[c]>temp)
            {
                temp=b[c];
                ans=c;
            }
        }
        if(temp>n-temp)
            printf("%d\n",ans);
        else
            printf("-1\n");

    }


    return 0;
}




标签:HDU,5364,temp,int,money,punished,ans,Output
From: https://blog.51cto.com/u_3936220/7091428

相关文章

  • HDU 5366
    ThemookjongTimeLimit:2000/1000MS(Java/Others)  MemoryLimit:65536/65536K(Java/Others)TotalSubmission(s):326  AcceptedSubmission(s):252ProblemDescription![](../../data/images/C613-1001-1.jpg)ZJiaQwanttobecomeastrongman,sohed......
  • HDU 2444
    TheAccomodationofStudentsTimeLimit:5000/1000MS(Java/Others)  MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):3561  AcceptedSubmission(s):1656ProblemDescriptionThereareagroupofstudents.Someofthemmayknoweachother,......
  • HDU 1698(线段树 区间更新)
    JustaHookTimeLimit:4000/2000MS(Java/Others)    MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):23481    AcceptedSubmission(s):11758ProblemDescriptionInthegameofDotA,Pudge’smeathookisactuallythemosthorr......
  • HDU 3829 Cat VS Dog 猫和狗(二分图)结题报告
    听学长说这道题很ex,但是思路想到的话还是挺简单的。可能是受上一道题(放置机器人)的启发,也是找互相冲突的点连线。但是并不是完全一样(废话)放置机器人那道题是找到冲突点连线后直接求最大匹配即可。这道题稍微把思路变换一下,求出最大完美匹配数\(n\)后,说明有\(n*2\)个人的喜好......
  • HDU7326 string magic(Easy Version)
    HDU7326stringmagic(EasyVersion)tag:回文自动机题目链接题意:多组样例,每组输入一字符串(长度1e5以内),输出满足下列条件的子串个数:该串由两个完全相同的回文串拼接而成做法:字符串的题目一般都比较板,洛谷的P4287可以说是这道题目的原题,我们先看看原题是怎么做的P4287双......
  • hdu7365 0 vs 1
    0vs1首先如果两端不同肯定只能直接选。两端都选不了直接失败。不妨设现在是zero在选,从左边来010101交替,如果先出现了一个00比如01010100.....10那么我们就能从这边选,因为one只能跟着我们选这边,最后会出现两边都是0的情况。从右边来同理。假如是0101010交替,那么肯定是平......
  • HDU 多校 Round #6 题解
    HDU多校Round#6题解\(\text{ByDaiRuiChen007}\)A.CountProblemLink题目大意求有多少个长度为\(n\),字符集大小为\(m\)的字符串有长度为\(n-k\)的周期。数据范围:\(n,m,k\le10^{18}\)。思路分析\(k=n\)时答案为\(m^n\),否则转为有长度为\(k\)的Border,答案......
  • ## HDU7328 Snake
    HDU7328Snaketag:容斥,生成函数题目链接题意:1到n个数,分成m组,组队元素排列顺序不同则为不同的组,且每组元素个数不能超过k,问有多少种方案。容斥做法:暂且不管排列的事情,先把问题看成求n个球,m个盒子,盒子不能为空,且每个盒子中球数不能超过k。要保证每盒球数不超过k,我们可通过容......
  • HDU 暑假多校 2023 第六场
    目录写在前面733673417345733773397338写在最后写在前面补题地址:https://acm.hdu.edu.cn/listproblem.php?vol=64,题号7336~7346。哈哈,单刷5题,我是只会做套路题的飞舞。Boc'z那个单曲太牛逼了,最喜欢的一首,但是live上唱的这首是真难绷。以下按个人向难度排序。7336显然......
  • #轮廓线dp#HDU 1400 Mondriaan's Dream
    题目传送门分析状压dp会TLE,考虑用轮廓线dp,设\(dp[i][j][S]\)表示现在处理到\((i,j)\)这个位置轮廓线上状态为\(S\)的情况二进制位为1表示左边或者上方有骨牌跨过轮廓线,然后分类讨论转移一下即可代码#include<cstdio>#include<cstring>usingnamespacestd;con......