This is AtCoder's Knapsack 1 (DP ). You have items with weights and values. Find the maximum value you can carry in a knapsack of capacity .
You've already learned this pattern with 0/1 Knapsack. The state is dp[][] = max value using first i items with capacity . The transition: take or skip each item. Apply what you learned. Watch out for the constraints: ≤ 100, ≤ . Standard 0/1 knapsack works perfectly here.