And so you could construct all subsets, check that the weight is less than the weight of the knapsack, and then choose the subset with the maximum value.
因此你可以构建所有子问题,判断它的重量,是否小于背包的重量,然后选择值最大的子问题。
Then the maximum value I can get is the maximum value of what I had.
我获得的最大值,就是我现有的总值。
Or a subset with the maximum value, there may be more than one, and you're done.
或者是有最大值的子问题集,可能不只一个子问题符合条件,然后就解决问题了。
And now we want to find the subset of a that has the maximum value, subject to the weight constraint.
会有一个值与其对应,现在我们想要找出满足,重量约束条件的a的最大值子集。
应用推荐