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 ...
随机推荐
- linux共享文件samba安装与java读取外部文件夹方法
测试环境RedHat 6.4 一.安装 samba组件安装: (1)首先用“rpm –qa |grep samba”命令检验系统samba服务是否安装. #rpm –qa |grep samba sa ...
- MySQL查看和修改字符编码
MySQL的默认编码是Latin1,不支持中文,要支持中午需要把数据库的默认编码修改为gbk或者utf8. 1.需要以root用户身份登陆才可以查看数据库编码方式(以root用户身份登陆的命令为:&g ...
- MySQL基础学习之数据查询
一般查询 SELECT * FROM 表名 SELECT 属性名 FROM 表名 条件查询 SELECT 属性名 FROM 表名 WHERE 条件表达式 查询数据值1,数据值2的表单 SELEC ...
- php 时间函数参考
time()在PHP中是得到一个数字,这个数字表示从1970-01-01到现在共走了多少秒,很奇怪吧 不过这样方便计算, 要找出前一天的时间就是 time()-60*60*24; 要找出前一年的时间就 ...
- mysql 远程连接 2003 Can't connect to MySQL server (10060)
mysql server 端的端口被防火墙挡出,没有开放
- SaveFileDialog控件
http://msdn.microsoft.com/zh-cn/library/system.windows.forms.savefiledialog.aspx 1,SaveFileDialog控件的 ...
- js事件之神奇的onclick
21:58 2013/7/1 <a href="#" onclick="alert(123124);" >链接</a> 意思是鼠标点击链 ...
- cocos2dx android平台事件系统解析
对于cocos2dx在android平台事件的响应过程很模糊,于是分析了下源码,cocos2dx 版本3.4,先导入一个android工程,然后看下AndroidManifest.xml <ap ...
- Python爬取17吉他网吉他谱
最近学习吉他,一张一张保存吉他谱太麻烦,写个小程序下载吉他谱. 安装 BeautifulSoup,BeautifulSoup是一个解析HTML的库.pip install BeautifulSoup4 ...
- cnn常用参数记录
1. epoch 在代码中经常见到n_epochs这个参数,该参数到底是什么意思呢?答案如下: 在一个epoch中,所有训练集数据使用一次 one epoch = one forward pass a ...