Define as the minimum weight needed to achieve exactly value using items to . Here ranges from to , and ranges from to where .
Base cases:
(zero items, zero value, zero weight needed)
for (impossible to get positive value with no items)
The transition mirrors the original knapsack. For each item , you either skip it and keep , or include it and check . You take the minimum of the two.