All submissions for this problem are available.
The problem we will be concerned with will be to minimize the number of coins that change hands at such a transaction, given that the shopkeeper has an adequate supply of all coins. (Indian coins comprise 5p, 10p, 20p, 50p, 1 Rupee and 2 Rupee.) Thus if we need to pay 55p, and we do not hold a 50p coin, we could pay this as 2*20p + 10p + 5p to make a total of 4 coins. If we tender 1Rupee we will receive 45p in change which also involves 4 coins, but if we tender $1.05 (1Rupee + 5p), we get 50p change and the total number of coins that changes hands is only 3.
Write a program that will read in the resources available to you and the amount of the purchase and will determine the minimum number of coins that change hands.
Input will consist of a series of lines, each line defining a query. Each line will consist of 6 integers representing the numbers of coins available to you in the order given above, followed by a real number representing the value of the transaction, which will always be less than 5.00 Rupee. The file will be terminated by six zeroes (0 0 0 0 0 0). The total value of the coins will always be sufficient to make up the amount and the amount will always be achievable, that is it will always be a multiple of 5p.
Output will consist of a series of lines, one for each situation defined in the input. Each line will consist of the minimum number of coins that change hands right justified in a field 3 characters wide.
Input: 2 4 2 2 1 0 0.95 2 4 2 0 1 0 0.55 0 0 0 0 0 0 Output: 2 3
|Time Limit:||5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.