Modified Knapsack
CodeChefOpen on judge ↗
Lukas was wandering in the market when he spotted a shop selling magical items. There are a total of N items for sale. Each item costs 1 gold coin and has a certain value and a certain weight. Lukas has M gold coins and decided to spend them all on magical items. This means he will buy exactly M out of the N items. Naturally, Lukas wants to maximize the sum of the values of the items he buys. At
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