← All problemsSign in

Ball Bag

Chiragh has $N$ balls and $M$ ball bags. Initially, all bags are empty, and each bag can contain only one ball. Each ball has a price and a bag number assigned to it. If you want to choose a ball, you must put it in its assigned bag, and of course, that bag can’t be used for any other ball. You need to choose some balls (with their bags) such that summation of their price is maximized. ###Input:

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start