标签:++ can pac 混合背包 int == logs amp ace
#include<cstdio> #include<algorithm> using namespace std; int n,V,op[20010],c[20010],w[20010],f[10010]; int main(){ scanf("%d%d",&n,&V); for(int i=1;i<=n;++i){ scanf("%d%d%d",&op[i],&c[i],&w[i]); } for(int i=1;i<=n;++i){ if(op[i]==2){ for(int v=V;v>=w[i];--v){ f[v]=max(f[v],f[v-w[i]]+c[i]); } } else{ for(int v=w[i];v<=V;++v){ f[v]=max(f[v],f[v-w[i]]+c[i]); } } } printf("%d\n",f[V]); return 0; }
标签:++ can pac 混合背包 int == logs amp ace
原文地址:http://www.cnblogs.com/autsky-jadek/p/6935084.html