#t554. 运动会奖牌榜
运动会奖牌榜
Medal Standings
Problem Description
After a sports meet, the medal standings of all participating countries must be compiled. Each country has a name, and a number of gold, silver, and bronze medals. The ranking rules are as follows:
- Gold medals: more comes first;
- If gold medals are equal, more silver medals comes first;
- If silver medals are also equal, more bronze medals comes first;
- If bronze medals are also equal, order by country name in ascending lexicographic order.
If two countries have exactly the same numbers of gold, silver, and bronze medals, they share the same rank. Subsequent ranks are assigned by the actual position after sorting. For example, after two countries tied at rank 1, the next country is rank 3.
Input Format
The first line contains an integer , the number of countries.
The following lines each contain a country's information: its name, number of gold medals, number of silver medals, and number of bronze medals. The country name contains no spaces.
Output Format
Output lines. Each line has the format: rank name gold silver bronze.
Sample Input
5
China 10 8 5
USA 10 10 3
Japan 8 12 10
Korea 10 10 3
France 5 5 5
Sample Output
1 Korea 10 10 3
1 USA 10 10 3
3 China 10 8 5
4 Japan 8 12 10
5 France 5 5 5
Sample Explanation
There are countries in total. After sorting:
- Korea and USA both have gold, silver, and bronze, so they tie for rank . Since "Korea" precedes "USA" lexicographically, Korea is listed first.
- China has gold, silver, bronze. Its gold equals Korea's and USA's, but it has fewer silver, so it ranks after them as rank .
- Japan has gold, silver, bronze, with fewer gold than the top three, so it is rank .
- France has gold, silver, bronze, the fewest gold, so it is rank .
Constraints
.