1 条题解
-
3
模板题
#include<iostream> using namespace std; int n,p,w[320001],v[320001],tot,f[5001],W,V,C; int main(){ cin>>n>>p; for(int i=1;i<=n;i++){ cin>>W>>V>>C; C=min(C,p/W); for(int j=1;j<=C;j<<=1){ w[++tot]=W*j; v[tot]=V*j; C-=j; } if(C>0){ w[++tot]=W*C; v[tot]=V*C; } } for(int i=1;i<=tot;i++){ for(int j=p;j>=w[i];j--){ f[j]=max(f[j],f[j-w[i]]+v[i]); } } cout<<f[p]; }
- 1
信息
- ID
- 488
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- (无)
- 递交数
- 178
- 已通过
- 87
- 上传者