http://acm.hdu.edu.cn/showproblem.php?pid=536

Distribution money

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

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
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a,h[];
int main()
{
int n;
while(~scanf("%d",&n))
{
memset(h,,sizeof(h));
int i;
for(i=;i<n;i++)
{
scanf("%d",&a);
h[a]++;
}
int max=,t;
for(i=;i<=;i++)
{
// printf("h=%d\n",h[i]);
if(h[i]>=max)
{
max=h[i];
t=i;
}
}
if(max>(n-max))
printf("%d\n",t);
else
printf("-1\n"); }
return ;
}
 

hdu-5364 Distribution money的更多相关文章

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

    题目:Click here 题意:bestcoder上面有中文题目 #include <iostream> #include <cstdio> #include <cst ...

  2. HDU 5291 Candy Distribution DP 差分 前缀和优化

    Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of ...

  3. HDU 5291 Candy Distribution

    Candy Distribution Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  4. HDU多校第三场 Hdu6606 Distribution of books 线段树优化DP

    Hdu6606 Distribution of books 题意 把一段连续的数字分成k段,不能有空段且段和段之间不能有间隔,但是可以舍去一部分后缀数字,求\(min(max((\sum ai ))\ ...

  5. HDU 5029 Relief grain(离线+线段树+启发式合并)(2014 ACM/ICPC Asia Regional Guangzhou Online)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5029 Problem Description The soil is cracking up beca ...

  6. HDU 5029 Relief grain 树链剖分打标记 线段树区间最大值

    Relief grain Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  7. POJ 3654 &amp; ZOJ 2936 &amp; HDU 2723 Electronic Document Security(模拟)

    题目链接: PKU:http://poj.org/problem?id=3654 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...

  8. HDU 1014 Uniform Generator【GCD,水】

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  9. hdu 5880 AC自动机

    Family View Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

随机推荐

  1. ajax返回json处理

    在JS中将JSON的字符串解析成JSON数据格式,一般有两种方式: 1.一种为使用eval()函数. 2. 使用Function对象来进行返回解析. (一)以jquery异步获取的数据类型--json ...

  2. Linux学习笔记2

    1.系统引导配置文件  # vi /boot/grub/grub.conf   default=0   timeout=5   splashimage=(hd0,0)/grub/splash.xpm. ...

  3. 《C和指针》读书笔记——第三章 数据

    1.typedef:为各种数据类型定义新名字 typedef char  *ptr_to_char; ptr_to_char a;//声明a是一个指向字符的指针. 2.链接属性:extern;stat ...

  4. 解决关于IIS10.0下无法安装 URL 重写模块 2的问题

    win10 系统自带的IIS是IIS10.0,官网提示URL Rewrite 2.0是只要IIS7.0以上的版本就可以安装,但是在IIS10.0下安装却一直失败.错误提示如下: 那么如何才能正确安装呢 ...

  5. 大话string

    最近看完大话string之后深有感悟,虽然写c#不知不觉的已经写了四年了,但是很多原理也一直不太明白,最近看完这个才算略微明白了一些. string类型有2个重要的特性,一致性和驻留性. 一致性就是说 ...

  6. linux下使用split 来分割大文件

    linux下使用split 来分割大文件 2010-07-27 15:46:27|  分类: 技术文稿 |  标签:split  分割  linux   |字号 订阅   平常都是使用ssh来进行远程 ...

  7. 用python实现k近邻算法

    用python写程序真的好舒服. code: import numpy as np def read_data(filename): '''读取文本数据,格式:特征1 特征2 -- 类别''' f=o ...

  8. Microsoft Visual Studio 2010 Service Pack 1(exe)

    在线安装包:https://cid-3ca83445bd7767a0.office.live.com/browse.aspx/.Public/VS2010 ISO:http://download.mi ...

  9. 将 Photoshop CC 2015.5 英文界面换成中文, 英文与中文界面互换

    注:转载或引用请注明出处 在英文的win server 2012 r2 上安装PS CC 2015.5 时,安装程序自动按成了英文版的PS,那么如何将英文换成中文呢? 网上大多讲的都是将中文换成英文, ...

  10. java.io.IOException: Cannot run program "bash": error=12, Cannot allocate memory

    java.io.IOException: Cannot run program , Cannot allocate memory 云服务器运行nutch报出的异常: 解决方案: http://daim ...