Dynamic Programming21 sections · 916 units
Open in Course

Applying 0/1 Knapsack

AtCoder DP D

This is AtCoder's Knapsack 1 (DP DD). You have nn items with weights and values. Find the maximum value you can carry in a knapsack of capacity WW.

You've already learned this pattern with 0/1 Knapsack. The state is dp[i][w]dp[i][w] = max value using first ii items with capacity ww. The transition: take or skip each item. Apply what you learned. Watch out for the constraints: nn ≤ 100, WW10510^5. Standard 0/1 knapsack works perfectly here.