You have item types. Each type has weight and value . You can take each type any number of times (including zero).
Your bag holds at most total weight. Find the maximum value. Example: Items are (, ) and (, ). Capacity . Take three of item 1: weight , value . But two of item 1 and one of item 2 gives weight , value . Best is .