题目传送门 解题思路: 一维解01背包,突然发现博客里没有01背包的板子,补上 AC代码: #include<cstdio> #include<iostream> using namespace std; ]; int main() { scanf("%d%d",&n,&m); ;i <= n; i++) { scanf("%d%d",&c,&w); ; j--) if(c <= j) f[j] =…
题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400),…
题目传送门:P2871 [USACO07DEC]手链Charm Bracelet 题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supp…
P2871 [USACO07DEC]手链Charm Bracelet 裸01背包. 看到自己1年半前写的30分code.......菜的真实(捂脸) #include<iostream> #include<cstdio> #include<cstring> #define re register using namespace std; int max(int a,int b){return a>b?a:b;} ],a,b; int main(){ scanf(&…
题目链接 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 52318   Accepted: 21912 Description Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N(1…
题目传送门 这道题明显就是个01背包.所以直接套模板就好啦. #include<bits/stdc++.h> #define MAXN 30000 using namespace std; int f[MAXN],w[MAXN],c[MAXN],n,v; int main(){ scanf("%d%d",&n,&v); ;i<=n;i++) scanf("%d%d",&w[i],&c[i]); ;i<=n;i+…
题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400),…
https://www.luogu.org/problem/show?pid=2871 题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the s…
就是 01 背包.大意:给您 \(T\) 个空间大小的限制,有 \(M\) 个物品,第 \(i\) 件物品的重量为 \(c_i\) ,价值为 \(w_i\) .要求挑选一些物品,使得总空间不超过 \(T\) ,且总价值最大. 考虑设 \(f_{i,j}\) 为 \(1\) ~ \(i\) 件物品,背包容量为 \(j\) 时的最大价值,那么假如不选第 \(i\) 件物品,则为 \(f_{i-1,j}\) 的子问题(背包内只有 \(i-1\) 个物品):若选,则为 \(f_{i-1,j-w_i}+v…
题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400),…