随笔分类 -  背包dp

摘要:problem有n个物品,价格为wi, 重要度为vi。在代价不超过m的情况下,最大化wi*vi的值n using namespace std;const int maxn = 40;int v[maxn], w[maxn], f[50005];int main(){ ... 阅读全文
posted @ 2018-07-24 09:33 gwj1139177410 阅读(131) 评论(0) 推荐(0)
摘要:problemsolutioncodes//dp[i+1][j]:从0到i+1这个物品中选出总重量不超过j的物品时总价值的最大值#include#includeusing namespace std;int n, s, w[5050], k[5050], dp[505... 阅读全文
posted @ 2018-06-04 21:56 gwj1139177410 阅读(82) 评论(0) 推荐(0)
摘要:problemsolutioncodes//数据太水,搜索就好#include#includeusing namespace std;int n, m, a[110];int search(int i, int r){ if(i == n)return r; ... 阅读全文
posted @ 2018-05-29 21:23 gwj1139177410 阅读(113) 评论(0) 推荐(0)
摘要:题面完全背包题解#includeusing namespace std;const int maxn = 100010;int n, m, c[maxn], w[maxn], f[maxn];int main(){ cin>>m>>n; for(int i... 阅读全文
posted @ 2018-04-30 17:33 gwj1139177410 阅读(99) 评论(0) 推荐(0)
摘要:题面01背包 注意输入线体积再物品个数题解//f[i][j]:当前在选第i个物品,剩余体积为j时能获得的最大价值。#includeusing namespace std;const int maxn = 1010;int n, m, w[maxn], v[maxn],... 阅读全文
posted @ 2018-04-30 17:31 gwj1139177410 阅读(137) 评论(0) 推荐(0)

选择