从左到右, 从右到左分别dp一次, 然后就可以回答询问了. ---------------------------------------------------------- #include<bits/stdc++.h> using namespace std; const int V = 1000; const int maxn = 1009; int L[maxn][maxn], R[maxn][maxn]; int w[maxn], v[maxn], c[maxn], N…
当时一直在想前缀和...多亏张队提醒... 从1到n背次包,保存每一个状态下的价值,就是不要把第一维压掉:再从n到1背一次,同样记住每种状态: 然后询问时相当于是max(前缀+后缀),当然前缀后缀中间去掉了一个应去掉的商品. #include<cstdio> #include<iostream> #define R register int using namespace std; inline int g() { R ret=,fix=; register :fix; +(ch^…
数据极水,不加优化的多重背包都能过...早知道考试的时候不加奇奇怪怪的卡常优化,卡了45分... 就是从前往后做一个多重背包,从后往前再做一个,问的时候就暴力求一下跳过这个的最佳方案... #include <iostream> #include <cstdio> #include <cstring> using namespace std; int f[1005][1005],g[1005][1005],n; struct VAN { int a,b,c; } p[1…
有一点乱搞吧......对人对背包的理解有些考验,要想知道去掉某个点的值,可以选择对前缀求一次背包,后缀求一次背包,而且不省掉价钱那一维, 这样每个点就可以由前后组合成了,枚举一下价钱取max即可 直接01的多重背包就可以过 #include<bits/stdc++.h> using namespace std; ; int n,m,q,ans,v[maxn],w[maxn],c[maxn]; int f[maxn][maxn],g[maxn][maxn]; int main(){ scanf…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…