This page is still under construction.

Parts of this page are still being built. What you see may change.

Life Savings

Interview

Time limit2sMemory limit512 MB

Summary
Compare the savings from one 20%-style whole-purchase coupon against the best way to spend two one-item coupons on two of three items, then print the winning plan and its savings.
Level

Easy2 of 10

Topics
Brute force, Math, Implementation, Greedy
Solved
No attempts yet

Problem

Stanley is careful with money. He lives simply and counts every penny he spends. The few people who call him a friend describe him as thrifty. He is a miser.

Stan never goes shopping without coupons, and right now he has a problem at the checkout. He wants three items with list prices of $100, $50 and $40. He holds three coupons. One takes 20% off the entire purchase and cannot be combined with any other coupon. The other two are one-item coupons, one for 30% off and one for 25% off, and he may use them together on two different items. Stan cannot tell whether the single whole-purchase coupon beats the two one-item coupons used together, and the line behind him is getting impatient. Work out for Stan which choice he should make and how much it saves.

Input

The input has two lines.

The first line has the list prices p1p_1, p2p_2, p3p_3 of the three items, separated by spaces. (1≤p1,p2,p3≤10001 \le p_1, p_2, p_3 \le 1000)

The second line has the discount percentages c1c_1, c2c_2, c3c_3 of the three coupons, separated by spaces. (1≤c1,c2,c3≤1001 \le c_1, c_2, c_3 \le 100) Coupon c1c_1 applies to the whole purchase and cannot be combined with any other coupon. Coupons c2c_2 and c3c_3 each apply to a single item, and the two may be used on two different items at the same time.

All values are integers. Prices are in dollars and discounts are in percent.

Output

Compare the amount saved by coupon c1c_1 alone with the largest amount that c2c_2 and c3c_3 can save on two different items. If the first amount is larger, print one. Otherwise print two. Then print a single space and the amount saved by the plan you printed. If the two amounts are equal, print two. Write the amount with exactly two digits after the decimal point and no dollar sign. Every possible saving is a whole number of cents.

Examples3

  1. Example 1

    Input
    100 50 40
    20 30 25
    
    Expected output
    two 42.50
    
  2. Example 2

    Input
    100 50 40
    25 30 25
    
    Expected output
    one 47.50
    
  3. Example 3

    Input
    11 37 24
    15 5 35
    
    Expected output
    two 14.15