Q : Given N containers, each container has balls of different colors, and each color can have multiple quantity in a single container. We need to select A quantity of color C1 , B quantity of color C2, C quantity of color C3 etc.↵
↵
Penalty is equal to sum of all leftover quantity in a container if something is picked from container, else 0.↵
We need to minimise the penalty and find set of containers which can help acheive minimum penalty.↵
↵
Example ↵
↵
container 1 — [ (c1, 100), (c2, 100), (c3, 50) ]↵
container 2 — [ (c1, 50), (c2, 50), (c3, 50) ]↵
container 3 — [ (c1, 50), (c2, 50), (c3, 80) ]↵
↵
↵
we need to pick (c1, 100), (c2, 100)↵
↵
1. If we select container 1 -> penalty = 50↵
↵
2. If we select container (2,3) -> penalty = (50+80) = 130↵
↵
So answer would be 50 and set of boxes would be [Container 1]↵
↵
↵
Constraints :↵
↵
Container Count <= 100,↵
Color Count <= 1000,↵
Max quantity of each color <= 500↵
↵
↵
↵
Time Limit : 60 seconds↵
↵
↵
↵
Penalty is equal to sum of all leftover quantity in a container if something is picked from container, else 0.↵
We need to minimise the penalty and find set of containers which can help acheive minimum penalty.↵
↵
Example ↵
↵
container 1 — [ (c1, 100), (c2, 100), (c3, 50) ]↵
container 2 — [ (c1, 50), (c2, 50), (c3, 50) ]↵
container 3 — [ (c1, 50), (c2, 50), (c3, 80) ]↵
↵
↵
we need to pick (c1, 100), (c2, 100)↵
↵
1. If we select container 1 -> penalty = 50↵
↵
2. If we select container (2,3) -> penalty = (50+80) = 130↵
↵
So answer would be 50 and set of boxes would be [Container 1]↵
↵
↵
Constraints :↵
↵
Container Count <= 100,↵
Color Count <= 1000,↵
Max quantity of each color <= 500↵
↵
↵
↵
Time Limit : 60 seconds↵
↵
↵