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 ...
随机推荐
- JAVA多线程---volatile关键字
加锁机制既可以确保可见性又可以保证原子性,而volatile变量只能确保可见性. 当把变量声明为volatile时候 编译器与运行时都会注意到这个变量是共享的,不会将该变量上的操作与其他内存操作一起重 ...
- 关于Vue问题记录
第一次安装Vue时,npm run dev报错处理 1.如果是报错:提示说没找到test这个文件夹 参考资料:https://segmentfault.com/q/1010000010893904 就 ...
- SSH端口转发详解及实例
一.SSH端口转发简介 SSH会自动加密和解密所有SSH客户端与服务端之间的网络数据.但是,SSH还能够将其他TCP端口的网络数据通SSH链接来转发,并且自动提供了相应的加密及解密服务.这一过程也被叫 ...
- ADALINE模型
ADALINE模型即自适应线性单元(Adaptive Linear Neuron),主要用于信号处理中的自适应滤波.预测和模式识别.其结构图如下 输入向量X=(x0,x1,x2,...,xn)T每个输 ...
- MongoDB学习教程(1)
1.简介: MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统.在高负载的情况下,添加更多的节点,可以保证服务器性能.MongoDB 旨在为WEB应用提供可扩展的高性能数据 ...
- ch3-模板语法({{}} v-html v-bind:id 表达式 指令 修饰符 过滤器)
1 模板语法 Vue.js 使用了基于 HTML 的模版语法,允许开发者声明式地将 DOM 绑定至底层 Vue 实例的数据. 所有 Vue.js 的模板都是合法的 HTML ,所以能被遵循规范的浏览器 ...
- 用SqlCommandBuilder 实现批量更新
一般是这样的,如果用设计器将SqlDataAdapter拖到页面中使用时,不会出现SqlDataAdapter.Update(ds)更新时出错情况,因为系统会自动生成SqlDataAdapter的属性 ...
- 基于EF Core的Code First模式的DotNetCore快速开发框架
前言 最近接了几个小单子,因为是小单子,项目规模都比较小,业务相对来说,也比较简单.所以在选择架构的时候,考虑到效率方面的因素,就采取了asp.net+entity framework中的code f ...
- Android 屏幕相关概念(1)
1. 术语和概念 术语 说明 备注 Screen size(屏幕尺寸) 指的是手机实际的物理尺寸,比如常用的2.8英寸,3.2英寸,3.5英寸,3.7英寸 摩托罗拉milestone手机是3. ...
- chromium源码阅读--Browser进程初始化
最近在研读chromium源码,经过一段懵懂期,查阅了官网和网上的技术文章,是时候自己总结一下了,首先IPC message loop开始吧,这是每个主线程必须有的一个IPC消息轮训主体,类似之前的q ...