shopping(price, special, needs, memo)
that returns the minimum cost to satisfy the needs
.needs
state is in the memo
hashmap, return the stored result.res
with the cost of buying items at regular prices without any special offers.special
list.needs
.needs
).clone
needs.shopping(price, special, clone, memo)
to compute the cost after applying the offer.res
with the minimum of its current value and the cost of the offer plus the recursive call result.needs
state in the memo
hashmap.res
as the minimum cost for the current needs
state.