For each item and capacity , you have two choices:
Skip item : Keep the best value from items to with the same capacity. That's .
Take item : Add to the best value from items to with reduced capacity . That's . You can only take item if it fits: . The transition (the formula to compute each state) is: if , else iwiw.