hdu-5364 Distribution money
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
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.
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.
If
nobody should be punished,output -1.
#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的更多相关文章
- BestCoder Round #50 (div.1) 1001 Distribution money (HDU OJ 5364)
题目:Click here 题意:bestcoder上面有中文题目 #include <iostream> #include <cstdio> #include <cst ...
- HDU 5291 Candy Distribution DP 差分 前缀和优化
Candy Distribution 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5291 Description WY has n kind of ...
- HDU 5291 Candy Distribution
Candy Distribution Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU多校第三场 Hdu6606 Distribution of books 线段树优化DP
Hdu6606 Distribution of books 题意 把一段连续的数字分成k段,不能有空段且段和段之间不能有间隔,但是可以舍去一部分后缀数字,求\(min(max((\sum ai ))\ ...
- 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 ...
- HDU 5029 Relief grain 树链剖分打标记 线段树区间最大值
Relief grain Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- POJ 3654 & ZOJ 2936 & HDU 2723 Electronic Document Security(模拟)
题目链接: PKU:http://poj.org/problem?id=3654 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?proble ...
- HDU 1014 Uniform Generator【GCD,水】
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu 5880 AC自动机
Family View Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
随机推荐
- 用Objective-C的foundation框架解决表达式求值问题
主要思想: 本程序分2个类 一个是ExpressionString类,主要用于存储表达式以及对它进行求值.以下是该类中的内容: (NSString *)expString//用于存储要计算的表达式: ...
- unix 常用命令
(一)基本命令 命令格式: 命令 参数 1.ls 显示文件名,等同于dos下dir命令 命令格式:ls [option] file option: -l 显示详细列表 域1 :文件类型和文件权限 域2 ...
- Pycharm使用技巧
1.代码配色,即主题 pycharm自带的配色方案都很难看,网上的配色方案又很难看,所以根据其他ide的Monokai配色方案,自己定义了一个. pycharm Monokai主题下载:http:// ...
- python模块之os和os.path模块
1.os模块os.listdir(dirname) 列出dirname下的目录和文件os.getcwd()函数得到当前工作目录,即当前Python脚本工作的目录路径.os.getenv()和os.pu ...
- Sybase数据库异常紧急恢复
现象:Error 926 Severity Level 14 Error Message Text Database 'xx' cannot be opened - it has been ma ...
- LogBack入数据库重写
项目需要:将info以及error的日志信息写入到数据库中:同时所有的日志都要写入到日志文件中. 可以封装一下,在基类的logError/logInfo中调用了log.error()以及log.inf ...
- C#.net调用axis2webService
用C#.net调用axis2webService的时候需要引用web服务, 比如访问地址为:http://111.21.32.213:8080/axis2/services/AdService/get ...
- ubuntu下的文本查看相关命令
文本查看 1.cat命令(查看文本内容) 使用时三种常用模式 (1)cat 文本名 直接查看文本内容 (2)cat 文本名 -n 直接查看文本内容,但为文本中所有行编号 (3)cat 文本名 -b 直 ...
- BZOJ 1709: [Usaco2007 Oct]Super Paintball超级弹珠
Description 奶牛们最近从著名的奶牛玩具制造商Tycow那里,买了一套仿真版彩弹游戏设备(类乎于真人版CS). Bessie把她们玩游戏草坪划成了N * N(1 <= N<= 1 ...
- 总结: Struts2 + Spring 的线程安全问题
1. 首先Struts2 本身是安全的 其原理大概是:Strtus2会获取到用户的http请求,然后负责给每个请求实例化一个Action 对象,但是大家注意,这里的action对象和Struts1里面 ...