The Knapsack problem
Given a set of items, where each has a value and a weight
. We would like to pick certain items to maximize the total value, subject to the constraint that the total weight is at most
.
We are looking for a subset
such that
and
is as large as possible.
.
.
Dynamic programming solution
Reference: Christos H. Papadimitriou. Computational Complexity. Addison-Wesley, 1994. ISBN 0-201-53082-1