51nod1085---背包问题(51nod基础:01背包)
来源:互联网 发布:微博淘宝客发产品软件 编辑:程序博客网 时间:2024/06/05 06:48
【题目来源】:https://www.51nod.com
【题意&&思路】
只需一套模板。。。当然,,已经一想就出来了。。。dp数组里存的是容量为i的最大价值。。更新就是了。
【代码】
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;int a[105];struct pp{ int w,value;} b[105];int dp[10000+10];int main(){ int n,w; scanf("%d%d",&n,&w); for(int i=1; i<=n; i++) scanf("%d%d",&b[i].w,&b[i].value); for(int i=1; i<=n; i++) for(int j=w; j>=b[i].w; j--) dp[j]=max(dp[j],dp[j-b[i].w]+b[i].value); printf("%d\n",dp[w]);}
阅读全文
0 0
- 51nod1085---背包问题(51nod基础:01背包)
- 51NOD1085背包问题
- 51nod1085背包问题
- 51nod 1085 背包问题【01背包】
- 51nod 1085 背包问题【01背包】
- 51nod-1085 背包问题【01背包】
- 51Nod 1085 背包问题(01背包 )
- 【51Nod】1085 - 背包问题(01背包)
- 51nod 1085 背包问题(01背包)
- 0-1背包问题 51NOD(01背包)
- 背包问题-----51Nod
- 51nod-正整数分组问题(基础方程DP-01背包)
- 51nod 1086 背包问题 V2(多重背包问题)
- 51nod-1086 背包问题(多重背包)
- 01背包及完全背包问题(51Nod
- 51Nod 1086背包问题V2(多重背包)
- 51nod 1086 背包问题 V2(多重背包)
- 51Nod-背包问题V2(多重背包+二进制优化)
- Graham凸包算法简介
- JavaNIO,AIO进阶二
- Verilog数组表示及初始化
- 坚持#第187天~7月汇报情况
- mysql安装后出现登录错误的提示
- 51nod1085---背包问题(51nod基础:01背包)
- jquery ajax同步
- Mybatis3.3.x:StatementHandler(Box stop here)
- C#中正则表达式的3种匹配模式
- Configure python plug-in in eclipse
- Makefile 问题总结
- [第五季]13.后代选择器和属性选择器
- 微服务架构(二):融入微服务的企业集成架构
- 两种JDBC方式完成数据库连接