407128: GYM102697 099 Autobahn

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

099. Autobahntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Autobahn

You are about to drive on the Autobahn. You have several different cars, and you're trying to decide which one to take on the Autobahn. The different cars have differing fuel efficiencies, measured in miles per gallon (MPG), and the cars have different top speeds. You calculate a car's score as its fuel efficiency (MPG) multiplied by its top speed.

Given the list of possible cars, your task is to sort them by their score.

Input

The first line of input contains a single positive integer $$$n$$$: the number of cars. The next $$$n$$$ lines each contain the data for a car: the name of the car, its fuel efficiency in MPG, and its top speed.

Output

Output $$$n$$$ lines, each consisting of a car, sorted by their score as described above. Each line should be in the same format as its corresponding line in the input file. The car with the lowest score should appear first, and the car with the highest score should appear last. If two or more cars have equal scores, sort them alphabetically by the names of each car.

ExampleInput
5
Porsche 8 200
Ferrari 7 250
Lamborghini 6 220
BMW 5 230
MercedesBenz 10 160
Output
BMW 5 230
Lamborghini 6 220
MercedesBenz 10 160
Porsche 8 200
Ferrari 7 250

加入题单

上一题 下一题 算法标签: