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. Oracle笔记1

    ORACLE: 目前分为12C(cloud云)和11G(grid网格)版本 --数据库基本概念 data--数据 database--数据库 DBMS--数据库管理系统 RDBMS--关系型数据库管理 ...

  2. 掌握 ActionResult

    我在上一篇博客不要停留在表面,MVC 3 我们要深入一些 说明了我们的掌握程度还是不够,还需要我们继续努力.但是有园友质疑说他们认为我说的只是书院派,并不实用,这令作为程序员的我很是生气.好吧,那咱们 ...

  3. 面试题(C#基础)

    1>构造器Constructor不能被继承,因此不能重写Overriding,但可以被重载Overloading. 2>string[] ss=Enum.GetNames(typeof(C ...

  4. HTML5小时钟

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  5. 整理grep实战文本搜索过滤技巧

    一:grep的简介: 文本搜索工具,根据用户指定的文本模式对目标文件进行逐行搜索,显示能够被模式所匹配到的行.配合正则表达式的使用可以实现强大的文本处理.下面一一说明正则的例子. 二:文本处理工具分类 ...

  6. python 调用第三方库压缩png或者转换成webp

    因为工作需要去研究了下png的压缩,发现转换成webp可以小很多,但是webp在手机上的解码速度比png的解码速度慢很多.出于进几年手机设备的处理器的性能也不错了,所以准备两套方案. 在网上搜索了一些 ...

  7. opengl打开本地bmp图片绘制

    注意bmp图片的格式问题,32位ARGB  或者24位RGB.你所采用的素材一定要注意是多少位的就用多少位的.否则会显示错误的图片或者其他什么的错误. 代码如下 32位版本 #include < ...

  8. 【加密】RSA加密之实现

    private void btn_RSA_Click(object sender, EventArgs e) { //第一种方法调用 this.textBox1.Text = RSAEncrypt(& ...

  9. Winodws live writer

    发布一篇试试.

  10. BT5之网络配置

    输入ifconfig命令,可以查看当前IP地址设置情况.查看路由表的命令(用来检查默认网关是否设置正确):netstat -r 一.让BT5自动获取IP地址 自动获取IP地址,使用dhclient命令 ...