Sport Climbing Combined
InterviewTime limit1sMemory limit1024 MB
Given each athlete's ranks in three climbing events, sort them by the product of ranks, then by rank sum, then by bib number, and print the top three bib numbers.
- Level
Easy3 of 10
- Topics
- Sorting, Implementation, Array, Math
- Solved
- No attempts yet
Problem
Sport climbing is an indoor rock climbing sport that began in 1986. Competitors originally faced off only in lead climbing, then speed climbing was added in 1989, and bouldering was added ten years later in 1999. In the Olympic Games, athletes compete in the three events and are ranked overall to determine the gold, silver, and bronze medals. The overall ranking is decided by the product of the ranks earned in the three events. For example, if an athlete places 1st in lead, 5th in speed, and 2nd in bouldering, the score is 10. The athlete with the lower product ranks higher overall.
Given the bib numbers of athletes and the ranks they earned in the three events, write a program that determines the athletes who receive the gold, silver, and bronze medals. Two athletes may have the same product. In that case, the athlete with the lower sum of the three event ranks wins. If both the product and the sum are equal, the athlete with the lower bib number wins.
Input
The input uses standard input. The first line gives a positive integer (), the number of athletes. The following lines each give four integers , , , , where is the bib number of the -th athlete, and , , are the ranks that athlete earned in lead, speed, and bouldering, respectively. The bib numbers are distinct positive integers no greater than . Also, an athlete's rank in each event is an integer between and . Two athletes may have the same rank in an event.
Output
The output uses standard output. Print the three integers representing the bib numbers of the athletes who receive the gold, silver, and bronze medals, in that order, on one line.