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 ...
随机推荐
- [UIKit学习]04.关于HUD提示框,定时任务、开发关于资源常见问题
提示框的背景透明此时要设置background的Alpha值 定时任务 方法1:performSelector // 1.5s后自动调用self的hideHUD方法 [self performSele ...
- Vuforia开发完全指南---License Manager和Target Manager详解
License Manager和Target Manager License Manager 对于每一个用Vuforia开发的AR程序来说,都有一个唯一的license key,在Unity中必须首先 ...
- 高德地图JSApi
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- 关于逆元的概念、用途和可行性的思考(附51nod 1013 和 51nod 1256)
[逆元的概念] 逆元和单位元这个概念在群中的解释是: 逆元是指数学领域群G中任意一个元素a,都在G中有唯一的逆元a',具有性质a×a'=a'×a=e,其中e为该群的单位元. 群的概念是: 如果独异 ...
- The Nerd Factor SPOJ - MYQ5
The Nerd Factor Time Limit: 1000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Submi ...
- hdu3695 ac自动机入门
Computer Virus on Planet Pandora Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 256000/1280 ...
- hdu1878判断欧拉回路
欧拉回路 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- 22.Linux-块设备驱动之框架详细分析(详解)
本节目的: 通过分析块设备驱动的框架,知道如何来写驱动 1.之前我们学的都是字符设备驱动,先来回忆一下 字符设备驱动: 当我们的应用层读写(read()/write())字符设备驱动时,是按字节/字符 ...
- C# XML序列化
/// <summary> /// XML序列化为指定对象 /// Author:taiyonghai /// Time:2016-08-22 /// </summary> / ...
- web前端面试官挖的那些坑(js)
题目1: function Foo() { getName = function () { alert (1); }; return this; } Foo.getName = function () ...