S1 Dabbawalas Dilemma
All submissions for this problem are available.
The Dabbawalas Dilemma
The Dabbawalas in Mumbai have started finding the ever-increasing workload a bit too much lately.
Flooded with parcels every morning, they have decided to ask us programmers for some help.
They have to
transport n number of food parcels in food containers.
There are 4 types of food containers
- Type 1: Price p1 and can contain exactly n1 food parcels.
- Type 2: Price p2 and can contain exactly n2 food parcels.
- Type 3: Price p3 and can contain exactly n3 food parcels.
- Type 4: Price p4 and can contain exactly n4 food parcels.
Each of the containers is to be filled to its capacity and the cost of purchasing them should be minimised
The input file may contain multiple test cases. Each test case begins with a line containing the integer n
(n <= 20,000). The second line contains p1 and n1,third line contains p2 and n2,fourth line contains p3 and n3 and the fifth line contains p4 and n4 where ( 0 < p1, p2, p3, p4, n1, n2, n3, n4 < 20,000 ).
A test case in which n is zero in the first line ends the input sequence.
Output the number of type 1 containers, type 2 containers, type 3 containers and type 4 containers
required if a solution exists.
If not Output "Unsuccessful" without the double quotes.
Input: 10 2 3 3 4 4 5 5 6 12 6 7 7 8 8 9 9 10 0 Output: 2 1 0 0 Unsuccessful
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP 4.3.2, CPP 6.3, CPP14, GO, NODEJS|
Fetching successful submissions
If you are still having problems, see a sample solution here.