Buying Snacks

Interview

Time limit1sMemory limit1024 MB

Summary
Given price and weight for three snacks, print the name of the one whose 10-bag weight per discounted price is highest.
Level

Easy2 of 10

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

Problem

The convenience store in front of Namseo's house sells three kinds of snacks, named S, N, and U. The display shelf shows the price and weight of one bag. All bags of the same kind of snack have the same weight.

Namseo wants to buy 10 bags of snacks today. As a regular customer, Namseo has one discount coupon that takes 500 won off when the total purchase amount is at least 5,000 won. If the purchase amount is less than 5,000 won, the coupon cannot be used. The discount cannot be applied more than once.

When choosing snacks, Namseo cares about value for money. Namseo's value for money is the total weight divided by the total price. Namseo wants to eat snacks soon, so Namseo will pick 10 bags of a single kind of snack. Namseo will not buy anything else.

Value for money can be written mathematically as follows.

value for money = sum of the weights of 10 bags of snacks / money needed to buy 10 bags of snacks after accounting for the coupon

Looking at the shelf, Namseo found that the three snacks all have different values for money.

Which snack will Namseo buy?

Input

The input consists of three lines. Each line gives the price and weight of one bag, in that order, for S, N, and U, separated by a space.

Every input value is an integer between 1 and 1,000.

The values for money of the three kinds of snacks are guaranteed to be different.

Output

On the first line, print the name of the snack with the highest value for money (S, N, or U).

Examples1

  1. Example 1

    Input
    8 5
    6 6
    7 5
    
    Expected output
    N