HDUOJ---1171
http://acm.hdu.edu.cn/showproblem.php?pid=1171
Big Event in HDU
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18439 Accepted Submission(s): 6457
The splitting is absolutely a big event in HDU! At the same time, it is a trouble thing too. All facilities must go halves. First, all facilities are assessed, and two facilities are thought to be same if they have the same value. It is assumed that there is N (0<N<1000) kinds of facilities (different value, different kinds).
A test case starting with a negative integer terminates input and this test case is not to be processed.
#include<iostream>
#include<cstdlib>
using namespace std;
typedef struct Node
{
int value;
int num;
}node;
int cmp( const void *a, const void *b)
{
return (*(node*)b).value-(*(node*)a).value;
}
int main()
{
int n,i,sum,count,min;
node arr[];
while(cin>>n,n>)
{
for(sum=i=;i<n;i++)
{
cin>>arr[i].value>>arr[i].num;
sum+=arr[i].value*arr[i].num;
}
qsort(arr,n,sizeof(arr[]),cmp);
min=;
for(count=i=;i<n;i++)
{
while(arr[i].num)
{
if(count+arr[i].value<=sum/)
{
count+=arr[i].value;
}
arr[i].num--;
}
if(min<count)
{
min=count;
}
}
cout<<sum-min<<" "<<min<<endl;
}
return ;
}
HDUOJ---1171的更多相关文章
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- 1171. Lost in Space
http://acm.timus.ru/problem.aspx?space=1&num=1171 一天的时间,WA了N遍,居然是因为数组开小了呀,我勒个去!鄙视自己...... 我是从第 1 ...
- 【BZOJ-2892&1171】强袭作战&大sz的游戏 权值线段树+单调队列+标记永久化+DP
2892: 强袭作战 Time Limit: 50 Sec Memory Limit: 512 MBSubmit: 45 Solved: 30[Submit][Status][Discuss] D ...
- HDU 1171 Big Event in HDU 多重背包二进制优化
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1171 Big Event in HDU Time Limit: 10000/5000 MS (Jav ...
- hdu(1171)多重背包
hdu(1171) Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- hdu 01背包汇总(1171+2546+1864+2955。。。
1171 题意比较简单,这道题比较特别的地方是01背包中,每个物体有一个价值有一个重量,比较价值最大,重量受限,这道题是价值受限情况下最大,也就值把01背包中的重量也改成价值. //Problem : ...
- Codevs 1171 潜伏者 2009年NOIP全国联赛提高组
1171 潜伏者 2009年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description [问题描述] R 国和S 国正陷 ...
- [HDOJ 1171] Big Event in HDU 【完全背包】
题目链接:HDOJ - 1171 题目大意 有 n 种物品,每种物品有一个大小和数量.要求将所有的物品分成两部分,使两部分的总大小尽量接近. 题目分析 令 Sum 为所有物品的大小总和.那么就是用给定 ...
随机推荐
- 在JTextField中监听回车键,并执行相应按钮
在jbInit() 中加入jTextField1的按键监听,代码如下: jTextField1.addKeyListener(new KeyAdapter(){ public voi ...
- [实时更新]jquery全部版本号下载
jquery-2.1.0 注!不再支持IE 6/7/8 直接引用地址: 开发版地址1: <script src="http://code.jquery.com/jquery-2. ...
- Linux获取当前时间
代码(可以把clock_gettime换成time(NULL)) void getNowTime() { timespec time; clock_gettime(CLOCK_REALTIME, &a ...
- Longest Consecutive Sequence leetcode java
题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequenc ...
- 关于NLPIR应用在KETTLE中的探索
一:什么是NLPIR? NLPIR汉语分词系统(自然语言处理与信息检索共享平台),主要功能包括中文分词:词性标注:命名实体识别:用户词典功能:支持GBK编码.UTF8编码.BIG5编码.新增微博分词. ...
- (转)[原创]在ios android设备上使用 Protobuf (使用源码方式)
自:http://game.ceeger.com/forum/read.php?tid=13479 如果你的工程只能以.Net 2.0而不能以.Net 2.0 subset运行,请看另外一个方法. 地 ...
- jquery解析XML及获取XML节点名称
).tagName $().tagName [].tagName[] $(].tagName context.nodeName $(this).context.nodeName function ge ...
- sed 常用的功能
1.每行后面加入一个空行 sed 'G' num.txt,保留空间(Hold Space)的内容默认值是一个空行.2.每行前面加入一个空行 sed '{x;p;x}' num.txt,交换模式空间和保 ...
- shiro实现基于机构加username的验证以及rememberMe
一.Shiro的一些经验与rememberMe实现原理 Shiro的登录(Authorization)和验权(Authentication).默认都是依据usernameUserName来做验证和授权 ...
- freemarker 模板开发入门
数据模型 scalars标量:从根 root 開始指定它的路径,每级之间用点来分隔. 如:whatnot.fruits sequences 序列:使用数组的方括号方式来訪问一个序列的子变量. 如:an ...