Inverse Knapsack
CodeChefOpen on judge ↗
You are given $N$ and there exists an array of $N$ items, which only the Chef knows. The i-th item of the array will have a weight ($W_i$) and a profit ($P_i$) value associated with it. You are allowed to ask the chef the value of $dp[i][j]$, for a given $i, j$ where $dp[i][j]$ denotes the maximum amount of profit you can earn if you pick the best subset of items from the first $i$ items of the
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start