hdu1171-01背包
来源:互联网 发布:淘宝自动充值 编辑:程序博客网 时间:2024/04/30 08:44
Big Event in HDU
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 34637 Accepted Submission(s): 12013
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
/*01背包*/#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int val[5005];int dp[250050];int main(){ int n,v,m,a,b,l,sum,i,j; //freopen("in.txt","r",stdin); while(scanf("%d",&n)!=EOF&&n>0){ memset(dp,0,sizeof(dp)); l=0; sum=0; for ( i = 0; i < n; ++i) { scanf("%d%d",&a,&b); while(b--){ val[l++]=a; sum+=a; } } for ( i = 0; i < l; ++i) { for ( j = sum/2; j >=val[i] ; j--)//01背包 { dp[j]=max(dp[j],dp[j-val[i]]+val[i]); } } printf("%d %d\n", sum-dp[sum/2],dp[sum/2]); } return 0;}
0 0
- HDU1171(01背包)
- hdu1171-01背包
- HDU1171--01背包
- hdu1171 01背包
- hdu1171 01背包
- hdu1171 01背包 | 多重背包
- hdu1171 转化01背包,组合
- hdu1171(01背包变形)
- hdu1171(01背包问题)
- HDU1171:Big Event in HDU(01背包)
- hdu1171 Big Event in HDU 01-背包
- hdu1171 Big Event in HDU 01背包
- HDU1171 一维01背包DP
- hdu1171 Big Event in HDU --01背包
- HDU1171:Big Event in HDU(01背包)
- HDU1171--Big Event in HDU--01背包,多重背包
- hdu1171多重背包
- hdu1171多重背包
- MySQL一个字段部分包含在另一个字段中
- 比in效率更高的sql查询语句
- java split
- Nginx配置文件nginx.conf中文详解
- MVC过滤器详解
- hdu1171-01背包
- cnpm 安装
- Swift练习一: 使用TableView展示数据
- PHP脚本执行效率性能检测之WebGrind的使用
- Q1010 Tempter of the Bone C++ (深度优先搜索)
- velocity基础教程--3用velocity代替jsp作为程序视图展示
- Android项目笔记六:自定义的wificlass
- iOS开发笔记--使用blend改变图片颜色
- android studio运行直接进入了上次打开的项目,没有第一次打开的选择窗口