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 ...
随机推荐
- Tomcat 配置MySQL连接池
<!--配置mysql数据库的连接池, 需要做的额外步骤是将mysql的Java驱动类放到tomcat的lib目录下 maxIdle 连接池中最多可 ...
- Flipping an Image
Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resu ...
- Exp4 恶意代码分析 20165110
Exp4 恶意代码分析 20165110 一.实践目标 1.是监控你自己系统的运行状态,看有没有可疑的程序在运行. 2.是分析一个恶意软件,就分析Exp2或Exp3中生成后门软件:分析工具尽量使用原生 ...
- mysql表理解
4.1 索引组织表 1.在innodb存储引擎中,每张表都有个主键,如果在创建表时没有显式地定义主键,则innodb存储引擎会按如下方式选择或创建主键: ①:首先判断表中是否有非空的唯一索引,如果有, ...
- mapreduce 学习笔记
mapreduce基础概念 mapreduce是一个分布式计算框架(hadoop是mapreduce框架的一个免费开源java实现). mapreduce要点 主节点(master node)控制ma ...
- Laravel 学习笔记
1. 简介 2. 运行环境要求 2.1 PHP版本 >= 5.5.9 2.2 Mcrypt PHP 扩展 --------------------------php的加密扩展,提供多种加密算法 ...
- TZOJ 5694 区间和II(树状数组区间加区间和)
描述 给定n个整数,有两个操作: (1)给某个区间中的每个数增加一个值: (2)查询某个区间的和. 输入 第一行包括两个正整数n和q(1<=n, q<=100000),分别为序列的长度和操 ...
- 关于TCP窗口大小
窗口字段 TCP Window字段用于接收端通知发送端:接收端当前能够接收的字节数(即当前允许发送端发送的字节数).在TCP Header中占有16bit长度,如下所示 0 1 2 3 0 1 2 3 ...
- Similarity measure
1. https://blog.csdn.net/m0_37676632/article/details/68936157 2. https://www.cnblogs.com/pinard/p/62 ...
- Read-only file system
mount -o remount rw /