(DP,背包,只有价值)Big Event in HDU -- HDOJ
来源:互联网 发布:qq远程控制软件 编辑:程序博客网 时间:2024/06/07 12:47
Big Event in HDU
Problem Description
Nowadays, we 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
#include<iostream>#include<stdio.h>#include<algorithm>#include<string.h>#include<queue>#include<math.h>using namespace std;int num[100005];int dp[100005];long long sum=0;int cnt = 0;int main(void){ // freopen("in.txt","r",stdin); int n; while(scanf("%d",&n) && n>0) { cnt = 0; sum = 0; memset(dp,0,sizeof(dp)); for(int i=0; i<n; ++i) { int v,nm; scanf("%d %d",&v,&nm); sum += v*nm; for(int j=0; j<nm; ++j) num[cnt++] = v; } for(int i=0; i<cnt; ++i) { for(int j=sum/2; j>=num[i]; --j) { dp[j] = max(dp[j-num[i]] + num[i],dp[j]); } } printf("%d ",sum-dp[sum/2]); cout <<dp[sum/2]<<endl; } return 0;}
阅读全文
0 0
- (DP,背包,只有价值)Big Event in HDU -- HDOJ
- hdoj 1171 Big Event in HDU(背包dp+母函数)
- HDOJ Big Event in HDU 多重背包
- HDOJ题目1171Big Event in HDU(多重背包)
- HDOJ 1171 Big Event in HDU(多重背包)
- HDOJ 1171 Big Event in HDU(01背包)
- HDU 1171 Big Event in HDU (DP--01背包)
- hdoj 1171Big Event in HDU【dp】
- Big Event in HDU-01背包(dp思想)
- HDOJ 1171 Big Event in HDU (多重背包) / (母函数)
- hdoj 1171 Big Event in HDU 【母函数】【01背包】
- Big Event in HDU (多重背包)
- hdu 1171 Big Event in HDU 费用可行性背包 dp
- HDU 1171 Big Event in HDU dp背包
- HDOJ Big Event in HDU
- Big Event in HDU 背包
- hdu1171 Big Event in HDU(DP)
- hdoj 1171 Big Event in HDU (母函数)(背包)
- CSDN博客迁移至Hexo之Html2Md服务(专为csdn打造)
- RHEL7下修复grub rescue问题
- shadowocks的搭建与配置(三)
- Java中的transient关键字
- 《双峪花园散记·第一篇》
- (DP,背包,只有价值)Big Event in HDU -- HDOJ
- BASE理论
- 设计模式---单例模式
- Android获取顶部应用的几种方法
- fork系统调用底层实现源码剖析
- python基础(列表,字符串,字典)
- 【持久化框架】Mybatis简介与原理
- 数据库面试常问的一些基本概念
- Latex的复杂插图设置(并排、竖排等等)