#C11081. Olympic Medal Tally Ranking
Olympic Medal Tally Ranking
Olympic Medal Tally Ranking
You are given the medal tally of several countries from the Olympic Games. Each country has won a number of gold, silver, and bronze medals. The ranking is determined based on the following criteria:
- The country with the higher number of gold medals is ranked higher.
- If two countries have the same number of gold medals, the one with more silver medals is ranked higher.
- If the gold and silver medals are equal, the one with more bronze medals is ranked higher.
Formally, if a country has medal counts ( (G, S, B) ), then the ranking is determined by sorting the list in descending order with respect to (G), then (S), and finally (B).
Given a target country, your task is to determine its ranking position in this sorted list. If the target country is not found, output (-1).
inputFormat
The input is read from standard input (stdin) with the following format:
- The first line contains an integer (n) representing the number of countries.
- Each of the next (n) lines contains a string and three integers separated by spaces. The string represents the country name and the integers represent the numbers of gold, silver, and bronze medals, respectively.
- The last line contains the target country's name.
outputFormat
Output a single integer to the standard output (stdout), which is the ranking position (1-indexed) of the target country after sorting the countries by their medal counts as described. If the target country is not present in the list, output (-1).## sample
5
USA 10 5 8
CHINA 8 10 5
JAPAN 10 5 6
GERMANY 5 6 7
RUSSIA 8 7 10
JAPAN
2