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 ...
随机推荐
- Python 的xlutils模块
python模块: xlrd:读取excel xlwt:写入excel 缺点:excel格式无法复用 推荐xlutils模块 可复制原excel格式 from xlutils.copy import ...
- ABAP开发规范
一.数据库操作 1.禁止修改系统标准表. 2.如果使用到FOR ALL ENTRIES IN语句取数,一定要校验关联内表非空性. 3.禁止一条SELECT关联的表超过5张,需要多表取值的时候建议分开取 ...
- vue学习笔记(WebStorm安装)
慕课网:https://www.imooc.com/video/18553 一.前往官网下载:https://www.jetbrains.com/webstorm/download/#section= ...
- 监控服务器配置(一)-----Prometheus安装配置
最近和朋友一起做的监控配置,拿出来共享一下 1.下载prometheus安装包(linux版)到 /opt/minitor/prometheus . 下载地址:https://download.csd ...
- C语言编写程序计算圆上的点的坐标
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- vue间通信
1,父子组件通信 props 传递 父组件: 子组件: 2,子父组件通信 父组件: 子组件: 3,子组件与子组件传递 使用bus.js 如下 传递子组件: 接收子组件
- Centos启动流程及grub legacy
Linux系统的组成部分:内核+根文件系统 内核的功能:进程管理.内存管理.网络管理.文件系统.驱动程序.安全功能 系统在运行时要么就是在运行内核代码,要么就是在运行应用程序代码.如果一个程序大多数时 ...
- zz-人生感悟
1. 社交感想 首先来看一下聪明人和普通人的区别是什么? 普通人思考问题都是一步一步的来,由A推理出B,B推导到C,再推导出D,最后得出E,然而聪明人却可以由A直接推算到E. 这就像开车,普通人的是手 ...
- Vue+Webpack构建去哪儿APP_一.开发前准备
一.开发前准备 1.node环境搭建 去node.js官网下载长期支持版本的node,采用全局安装,安装方式自行百度 网址:https://nodejs.org/zh-cn/ 安装后在cmd命令行运行 ...
- XBee 802.15.4/Digimesh FAQs:如何为2.4G模块选择合适的信道
XBee 802.15.4模块和XBee Digimesh模块在硬件上完全相同,只是出厂带有不同固件,如果测试需要,这两个固件可以都可以互换烧入模块中. 如何为2.4G模块选择合适的信道 IEEE 8 ...