Hide

Problem E
Life Savings

Stanley is very prudent when it comes to his finances. He enjoys a somewhat spartan lifestyle and watches every penny he spends. Those few who call him friend view him as economical, abstemious, and parsimonious. He’s basically a miserly tightwad.

Stan will never go shopping unless he has coupons. At the moment he has a bit of a conundrum. There are three items he wants to buy which have list costs of $100, $50 and $40. He has one coupon for $20$% off his entire purchase which can’t be used with any other coupon, and two coupons — one for $30$% off any one item and one for $25$% off any one item — which can be used together. He’s not sure if using the first coupon by itself will save him more money than using the other two coupons together or vice versa, and the people standing in line behind him at the checkout counter are getting a little impatient. Can you help Stan with his problem and make cents out of this situation?

Input

Input consists of two lines. The first line starts with three positive integers $p_1$ $p_2$ $p_3$ ($p_1, p_2, p_3 \leq 1000$) which are the prices of three objects to be purchased. The second line contains three positive integers $c_1$ $c_2$ $c_3$ ($c_1, c_2, c_3 \leq 100$) where $c_1$ is the coupon percentage for the entire purchase (and cannot be used with any other coupon) and $c_2$ and $c_3$ are two one-item coupons (which can be used together but on separate items).

Output

If using the single entire-purchase coupon saves Stan more money, display the word one followed by the amount of savings; otherwise display the word two following by the best savings using the two one-item coupons. All savings should be output with two digits after the decimal point.

Sample Input 1 Sample Output 1
100 50 40
20 30 25
two 42.50
Sample Input 2 Sample Output 2
100 50 40
25 30 25
one 47.50
Sample Input 3 Sample Output 3
11 37 24
15 5 35
two 14.15

Please log in to submit a solution to this problem

Log in