Canadian Computing Competition: 2009 Stage 2, Day 2, Problem 3
You like to make purchases using coins, but you have a problem: you have so much change that it is too heavy in your pocket. You have devised a plan to reduce the weight of your change, and you need to write a program to help you execute it.
Here is your plan. The next purchase you make costs
If the store owes you
There are
You have
In
Input Specification
The first line contains three integers:
The next
The next
Output Specification
Output the minimum weight achievable rounded to two decimal places, if you can afford
the purchase. If you cannot afford the purchase, print too poor
.
Sample Input
3 4 7
1 1.00
5 2.00
20 9.00
10 1.00
2
2
2
2
2
2
2
Description of Sample Input
You have seven 5-cent coins, and are making a purchase of 3 cents. The denominations are 1-cent, 5-cents, 10-cents, and 20-cents, with respective weights of 1 gram, 2 grams, 1 gram and 9 grams.
Output for Sample Input
11.00
Description of Output for Sample Input
There are two optimal solutions. One is to spend three 5-cent coins, so that the store returns 12 cents to you, in the form of one 10-cent coin and two 1-cent coins. The other is to spend four 5-cent coins, so that the store returns 17 cents to you, in the form of one 10-cent coin, one 5-cent coin, and two 1-cent coins.
Comments