BC #50 1001 Distribution money

Distribution money

Accepts: 713

Submissions: 1881

Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 65536/65536 K (Java/Others)

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

 1 #include <stdio.h>
 2 #include <string.h>
 3
 4 int main()
 5 {
 6     int a[10005];
 7     int n,i,j,k,flg;
 8     while(scanf("%d",&n)!=EOF)
 9     {
10         flg=0;
11         memset(a,0,sizeof(a));
12         for(i=1;i<=n;i++)
13         {
14             scanf("%d",&k);
15             a[k]++;
16         }
17         for(i=0;i<10000;i++)
18         {
19             if(a[i]>(n-a[i]))
20             {
21                 flg=1;
22                 j=i;
23                 break;
24             }
25         }
26         if(flg==1)
27             printf("%d\n",j);
28         else
29             printf("-1\n");
30     }
31     return 0;
32 }

时间: 2024-07-31 11:14:07

BC #50 1001 Distribution money的相关文章

hdu 5364 (bc#50 1001) Distribution money

Distribution money Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 276    Accepted Submission(s): 163 Problem Description AFA want to distribution her money to somebody.She divide her money into

HDU 4907 (杭电BC#3 1001)Task schedule(水)

题目地址:HDU 4907 水题...不多说..哈希后从后往前遍历一遍就行了. 代码如下: #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <queue> #include <map> #include<a

hdu 5365 (bc #50 1002 )Run

Run Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 594    Accepted Submission(s): 265 Problem Description AFA is a girl who like runing.Today,he download an app about runing .The app can record

hdu 5366 (bc #50 1003) The mook jong

The mook jong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 269    Accepted Submission(s): 205 Problem Description ![](../../data/images/C613-1001-1.jpg) ZJiaQ want to become a strong man, so

HDU 4883 (BC#2 1001题)TIANKENG’s restaurant(水)

题目地址:HDU 4883 唉..最近得了一种惯性..刚学了什么就碰到个类似的就想用刚学的算法...原来这题如此简单..当时真是想多了.... 只要在需要变化的点上设置一个值,是增多少还是减多少.然后当遍历过来的时候加上或减去这个值就行了... 代码如下: #include <iostream> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h>

BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)

题目:Click here 题意:bestcoder上面有中文题目 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 #include <cmath> 6 #include <string> 7 #include <climits> 8 #include <vector> 9 #incl

hdu 5366 The mook jong 动态规划(BC 50 C题)

比赛的时候还是没做出来,BC又是做一题,估计又是要掉分了,慢慢提升,总会终结一题的命运... 思路: 动态规划,然而我刚开始学,并不会做啊...先是找规律找了半天,结果啥也没找出来,又开始深搜, 结果样例能过,交上超时了,深度太大啊,没有正确估算...赛后看了题解,动态规划真是神算法啊,简单几行就 搞定了.设一个数组d[n]表示地板总数(n>3)然后列出状态转移方程d[n] = d[n-1] + (d[n-3] + 1);可以 这样理解,n是在n-1个地板上加上一个地板,我们可以对这个新增的地板

BC #49 1001 Untitled

Untitled Accepts: 504 Submissions: 1542 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description There is an integer aa and nn integers b_1, \ldots, b_nb?1??,…,b?n??. After selecting some numbers from b_1,

hdu 5365 Run(BC 50 B题)(求四边形的个数)

本来准备睡觉,结果还是忍不住想把它A了,因为已经看了题解了, 题意:就是给你一些坐标,都是整数,求一些正多边形的数目,官方题解说是地球人都知道整数坐标构不成正三角形,正五边形和正六边形的...然而我并不知道...以后才知道... 所以呢这道题直接暴力就可以了,求正四边形的个数,这里判断是否是正四边形用的是四条边相等,而且两条对角线相等,并且边比对角线小,我也不知道是否这样一定是正四边形(...) 放代码: #include<iostream> #include<cstdio> #i