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 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

Source

BestCoder Round #50 (div.2)

水.

比赛的时候傻逼两发,妈蛋

没读完就break了....

/*************************************************************************
    > File Name: code/bc/#50/1001.cpp
    > Author: 111qqz
    > Email: [email protected]
    > Created Time: 2015年08月08日 星期六 19时02分16秒
 ************************************************************************/

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>
#define y0 abc111qqz
#define y1 hust111qqz
#define yn hez111qqz
#define j1 cute111qqz
#define tm crazy111qqz
#define lr dying111qqz
using namespace std;
#define REP(i, n) for (int i=0;i<int(n);++i)
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x7fffffff;
int cnt[10005];
int n;
int x;
int main()
{
    while (scanf("%d",&n)!=EOF)
    {
    bool flag = false;
    memset(cnt,0,sizeof(cnt));
    for ( int i = 0 ; i < n ; i ++ )
    {
        scanf("%d",&x);
        cnt[x]++;
        if (flag) continue;
        if (cnt[x]>n/2)
        {
        flag = true;
        cout<<x<<endl;
        }
    }
    if (!flag)
    {
        cout<<-1<<endl;
    }
    }
    return 0;
}
时间: 2024-09-28 07:34:01

hdu 5364 (bc#50 1001) Distribution money的相关文章

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

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 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 4883 (BC#2 1001题)TIANKENG’s restaurant(水)

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

HDU BestCoder Round #1 1001 逃生 【拓扑排序】

逃生 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description 糟糕的事情发生啦,现在大家都忙着逃命.但是逃命的通道很窄,大家只能排成一行. 现在有n个人,从1标号到n.同时有一些奇怪的约束条件,每个都形如:a必须在b之前. 同时,社会是不平等的

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个地板上加上一个地板,我们可以对这个新增的地板

HDU 5364 Distribution money

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 o