Variation on knapsack - minimum total value exceeding 'W'

前端 未结 2 1088
生来不讨喜
生来不讨喜 2020-12-01 08:48

Given the usual n sets of items (each unlimited, say), with weights and values:

w1, v1
w2, v2
...
wn, vn

and a target weight <

2条回答
  •  北海茫月
    2020-12-01 09:18

    Not too sure, but this might work. Consider the values to be the -ve of the values you have. The DP formulation would try to find max value for that weight which would be the least negative value in this case. Once you have a value, take a -ve of it for the final answer.

提交回复
热议问题