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 . Or take two of item 2 and one of item 1: weight , doesn't fit. Best is .