Problem S
all know that Computer College is the biggest department in HDU.
But, maybe you don't know that Computer College had ever been split
into Computer College and Software College in 2002.
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
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
A test case starting with a negative integer terminates input and
this test case is not to be processed.
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.
#include
#include
#define maxn 255555
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
int
n,m,v,f[maxn],dp[maxn];
while(~scanf("%d",&n),n>0)
{
memset(dp,0,sizeof dp);
int d=0,sum=0;
for(int l=0;l
{
scanf("%d%d",&v,&m);
for(int i=0;i
{
f[d++]=v;
sum+=v;
}//将数据记录到数组,并且求出虽多的价值数
}
for(int i=0;i
for(int j=sum/2;j>=f[i];j--)
{
dp[j]=max(dp[j],dp[j-f[i]]+f[i]);
}
printf("%d %d\n",sum-dp[sum/2],dp[sum/2]);
}
return
0;
}
Problem S的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- 简单实用的CSS网页布局中文排版技巧
由于汉字的特殊性,在css网页布局中,中文排版有别于英文排版.排版是一个麻烦的问题,小编认为,作为一个优秀的网页设计师和网页制作人员,掌握一些简单的中文排版技巧是不可或缺的,所以今天特意总结了几个简单 ...
- 优秀的CSS预处理----Less
Less语法整理 本人邮箱:kk306484328@163.com,欢迎交流讨论. 欢迎转载,转载请注明网址:http://www.cnblogs.com/kk-here/p/7601058.html ...
- latex使用笔记
1.图片自动浮动到最后一页单独占用一页 将表格中的 \begin{table}[h]\end{table} 改成 \begin{table}[H]\end{table} 即可 2.公式内容中字母之间空 ...
- 初识 JShell
Java9 现在吵得热火朝天,赶紧顺势学习一波喽! JDK9 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk9-dow ...
- ADALINE模型
ADALINE模型即自适应线性单元(Adaptive Linear Neuron),主要用于信号处理中的自适应滤波.预测和模式识别.其结构图如下 输入向量X=(x0,x1,x2,...,xn)T每个输 ...
- EXTENDED LIGHTS OUT poj1222 高斯消元法
EXTENDED LIGHTS OUT Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6443 Accepted: 42 ...
- http://codeforces.com/problemset/problem/847/E
E. Packmen time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- STM8学习 无法仿真原因Starting debug session... -> Emulator reset (usb://usb)... ** Connection error (usb://usb): swim error [30200]: st-link connection error
刚调试程序时,STlink总是连不上,一直提示: Starting debug session...-> Emulator reset (usb://usb)...** Connection e ...
- 在CentOS 7 上安装docker
Docker CE Install yum-utils, which provides the yum-config-manager utility: $ sudo yum install -y yu ...
- Java web 学习笔记 Html CSS 小节
HTML (Hyper Text Markup Language): HTML就是超文本标记语言的简写,是最基础的网页语言 HTML的版本: 2.0(IETF) 3.0(W3C) 4.01(W3 ...