HDOJ-1171 Big Event in HDU
来源:互联网 发布:mac修改桌面图标大小 编辑:程序博客网 时间:2024/05/21 20:36
01背包解法求出最接近总价值一半的值即可
#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#include<queue>#include<vector>#include <iostream>#include <sstream>using namespace std;struct Goods{ int v, m;}goods[55];int dp[130000];int main(){ // freopen("in.txt", "r", stdin); int n; while(cin >> n && n >= 0) { int s = 0, p; for(int i = 0; i < n ; i++) { cin >> goods[i].v >> goods[i].m; s += goods[i].v * goods[i].m; } memset(dp, 0, sizeof(dp)); p = s; s /= 2; dp[0] = 1; for(int i = 0; i < n; i++) for(int j = 0; j < goods[i].m; j++) for(int h = s; h >= goods[i].v; h--) dp[h] |= dp[h - goods[i].v]; for(int h = s; h >= 0; h--) if(dp[h]) { cout << p - h << " " << h << endl; break; } } return 0;}
0 0
- HDOJ 1171 Big Event in HDU
- HDOJ--1171--Big Event in HDU
- hdoj 1171Big Event in HDU【dp】
- HDOJ-1171 Big Event in HDU
- HDOJ 1171 Big Event in HDU
- hdoj-1171-Big Event in HDU
- hdoj-【1171 Big Event in HDU】
- HDOJ Big Event in HDU
- HDOJ 1171 Big Event in HDU解题报告
- hdoj 1171 Big Event in HDU(背包dp+母函数)
- HDOJ 1171 Big Event in HDU (多重背包) / (母函数)
- HDOJ题目1171Big Event in HDU(多重背包)
- 母函数之Big Event in HDU hdoj 1171
- HDOJ 1171 Big Event in HDU(多重背包)
- Big Event in HDU 【HDOJ-1171-母函数】
- HDoj-1171-Big Event in HDU-母函数
- hdoj 1171 Big Event in HDU 【母函数】【01背包】
- HDOJ-1171-Big Event in HDU 解题报告
- 大数据利器
- 普通二维码和带图片二维码生成
- 设计模式之 抽象工厂模式 Factory
- web学习之路—H5(四)
- hive安装配置实验
- HDOJ-1171 Big Event in HDU
- android源码里的单例模式和模版模式
- 从头认识Spring-2.7 自动检测Bean(3)-过滤器<context:exclude-filter/>
- Linux TCP
- 在Windows下编译Mapnik的依赖库
- HDU1839---Delay Constrained Maximum Capacity Path(SPFA+vector+二分)
- 内外网同时上网
- Ubuntu下搭建git服务器步骤
- 饿汉单例和懒汉单例