Dynamic Programming21 sections · 916 units
Open in Course

Knapsack 2 - Problem Statement

AtCoder DP E

This is Knapsack 2 from AtCoder DP Contest: You have n100n \le 100 items. Each item has weight wi109w_i \le 10^9 and value vi1000v_i \le 1000. Your bag holds weight W109W \le 10^9. Find the maximum value you can carry. The constraints are break the standard approach. O(nW)O(n \cdot W) is impossible when W=109W = 10^9.

You need a different DP formulation. Flip the DP: try dp[value] = minimum weight to achieve exactly that value.