POJ--3624
来源:互联网 发布:ibm人工智能 鲍勃迪伦 编辑:程序博客网 时间:2024/06/14 05:19
经典的0,1背包问题,将二维数组压缩为一维数组
#include<iostream>using namespace std;int dp[13000];int weight[13000];int value[13000];int main(){ int n,w_max; cin>>n>>w_max; for(int i=0;i<n;i++) { cin>>weight[i]>>value[i]; } for(int i=0;i<n;i++) { for(int j=w_max;j>=weight[i];j--) { dp[j]=(dp[j]>(dp[j-weight[i]]+value[i]))?dp[j]:(dp[j-weight[i]]+value[i]); } } cout<<dp[w_max]<<endl; return 0;}
0 0
- poj 3624&poj 1384
- poj 3624
- POJ 3624
- POJ--3624
- POJ 3624
- poj 3624
- 【POJ】 【3624】
- 【POJ】【3624】
- poj 3624
- poj 3624
- poj 3624
- Poj 3624
- POJ 3624
- poj 3624
- poj 3624 Charm Bracelet
- poj 3624 Charm Bracelet
- poj 3624 Charm Bracelet
- poj 3624 Charm Bracelet
- 独立开发者回顾自身失败经历及其教训
- 验证码
- IOS数据库操作SQLite3使用详解
- IOS与Objective-C学习记录(一)
- powerdesign中表的name和comment互换
- POJ--3624
- android 16进制/10进制/2进制转换
- SQL server排序函数细说
- WPF控件开发之自定义控件(1)
- 定时任务,定时下载FTP指定文件
- oracle实现类似split效果
- ArcGIS for IOS 动态图层或者图层图例信息(个人)
- 推荐系统开源软件列表汇总和点评
- (原)剑灵武器升级超级技巧!