B - Big Event in HDU
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).
InputInput contains multiple test cases. Each test case starts with a number N (0 < N <= 50 -- the total number of different facilities). The next N lines contain an integer V (0<V<=50 --value of facility) and an integer M (0<M<=100 --corresponding number of the facilities) each. You can assume that all V are different.
A test case starting with a negative integer terminates input and this test case is not to be processed.
OutputFor each case, print one line containing two integers A and B which denote the value of Computer College and Software College will get respectively. A and B should be as equal as possible. At the same time, you should guarantee that A is not less than B.
Sample Input
2
10 1
20 1
3
10 1
20 2
30 1
-1
Sample Output
20 10
40 40
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; struct De
{
int a,k;
};
De ch[]; int main()
{
int n,sum;
while(scanf("%d",&n) && n>=)
{
sum=;
for(int i=;i<n;i++)
scanf("%d %d",&ch[i].a,&ch[i].k),sum+=ch[i].a*ch[i].k;
int fb[];
memset(fb,,sizeof(fb));
for(int i=; i<n; i++)
for(int h=;h<ch[i].k;h++)
for(int j=sum/;j>=ch[i].a;j--)
fb[j]=max(fb[j],fb[j-ch[i].a]+ch[i].a);
printf("%d %d\n",sum-fb[sum/],fb[sum/]);
}
return ;
}
B - Big Event in HDU的更多相关文章
- HDU-1171 Big Event in HDU
Big Event in HDU Problem Description Nowadays, we all know that Computer College is the biggest depa ...
- Big Event in HDU
Description Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe ...
- Big Event in HDU(HDU1171)可用背包和母函数求解
Big Event in HDU HDU1171 就是求一个简单的背包: 题意:就是给出一系列数,求把他们尽可能分成均匀的两堆 如:2 10 1 20 1 结果是:20 10.才最均匀! 三 ...
- 组合数学 - 母函数的变形 --- hdu 1171:Big Event in HDU
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 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 ...
- Big Event in HDU[HDU1171]
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU1171——Big Event in HDU(母函数)
Big Event in HDU DescriptionNowadays, we all know that Computer College is the biggest department in ...
- Big Event in HDU(HDU 1171 多重背包)
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- hdu1171 Big Event in HDU 01-背包
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1171 Problem ...
- HDU1171-Big Event in HDU
描述: Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don ...
随机推荐
- Centos 7下网卡bonding配置之mode4
一.bonding技术 bonding(绑定)是一种linux系统下的网卡绑定技术,可以把服务器上n个物理网卡在系统内部抽象(绑定)成一个逻辑上的网卡,能够提升网络吞吐量.实现网络冗余.负载等功能,有 ...
- 100-days: twenty-eight
Title: Lawrence Ferlinghetti's(劳伦斯·费林盖蒂) enduring San Francisco(旧金山) 劳伦斯·费林盖蒂心中的旧金山,历久弥新 费林盖蒂:美国垮掉的一 ...
- 19-05【icloud】照片备份
icloud提供了免费的存储空间,5G,超过这个量需要单独购买空间:我用的是50G,每月6元. 如果在mac或者iphone上开启了本地的照片流,则会自动同步到icloud,同时各个设备的客户端(ip ...
- 淘宝API对接实例
以为公司祖传代码太多使用的PHP5.4.45版本,所以无法使用SDK包,只能原生自己写,踩了不少坑. 1.授权 https://oauth.taobao.com/authorize?response_ ...
- sqlserver改主键初始ID
- Unity 3D 如何修改新建脚本中的 C# 默认创建的 Script 脚本格式
首先在Unity的安装路径下找到 Unity5\Editor\Data\Resources\ScriptTemplates路径的(81-C# Script-NewBehaviourScript.cs. ...
- 浅谈spring为什么推荐使用构造器注入
转载自: https://www.cnblogs.com/joemsu/p/7688307.html 一.前言 Spring框架对Java开发的重要性不言而喻,其核心特性就是IOC(Inversi ...
- asp.net asp.net application 升级到 asp.net web 解决找不到控件 批量生成.designer文件
颇费周折后,其实很简单,只需要生成designer文件后,重新保存所有页面即可.就是懒得写.懒真的是一种病,手上不能懒,脑子里更不能懒,否则就是给自己挖坑,仔细认真,注意细节!!!! PS:注意修改p ...
- java 实现udp通讯
需求:应用A(通常有多个)和应用B(1个)进行 socket通讯,应用A必须知道应用B的ip地址(在应用A的配置文件中写死的),这个时候就必须把应用B的ip设成固定ip(但是某些时候如更换路由后要重新 ...
- 大白书中无向图的点双联通分量(BCC)模板的分析与理解
对于一个无向图,如果任意两点至少存在两条点不重复(除起点和终点外无公共点)的路径,则这个图就是点双联通. 这个要求等价于任意两条边都存在于一个简单环(即同一个点不能在圈中出现两次)中,即内部无割点. ...