lijian1 2015-05-24 03:11:37
点我顶贴
收藏
删除
#include <cstdio>
using namespace std;
int f[501];
int main()
{ int N,V,m,w,s;
int i,t,tw,ts;
scanf("%d%d",&N,&V);
for (;N;--N)
{ scanf("%d%d%d",&m,&w,&s);
for (t=1;m;t<<=1)
{ if (t>m) t=m;
tw=t*w;
ts=t*s;
for (i=V;i>=tw;--i)
if (f[i-tw]+ts>f[i]) f[i]=f[i-tw]+ts;
m-=t; } }
printf("%d",f[V]);
return 0;}