01背包

· · 算法·理论

for(int i=1;i<=n;i++){
    for(int j=W;j>=w[i];j--){
        f[j]=max(f[j],f[j-w[i]]+v[i]);
    }
}