Up to ten thousand autonomous rally-racer robots complete a single timed obstacle course, and the event judges score each robot's run the instant it crosses the finish line -- so the robots are listed in the order they finished, not sorted by score. After the run, the event announcer must read out a placement label for every robot, in that same original order: the robot with the highest score earns "Gold Medal", the second-highest "Silver Medal", the third-highest "Bronze Medal", and every other robot is simply announced by its numeric placement written as a string (e.g. "4", "5", ...). No two robots ever record the same score. Given the scores in finishing order, produce the placement label for each robot, keeping the original order.
Line 1: an integer n, the number of robots. Line 2: n space-separated integers score_1 ... score_n, the score of each robot in finishing order.
Print n lines. Line i must contain the placement label of the i-th robot from the input (in the same order): "Gold Medal", "Silver Medal", or "Bronze Medal" for the top three scores, or the decimal string of the 1-indexed placement for every other robot.
Example 1
Input
5 7 12 3 9 15
Expected
4 Silver Medal 5 Bronze Medal Gold Medal
Explanation
The scores in finishing order are [7, 12, 3, 9, 15]. Sorting from highest to lowest gives 15, 12, 9, 7, 3, so the placements are 15->1st (Gold Medal), 12->2nd (Silver Medal), 9->3rd (Bronze Medal), 7->4th, 3->5th. Reading the labels back in the original finishing order (7, 12, 3, 9, 15) gives "4", "Silver Medal", "5", "Bronze Medal", "Gold Medal", one per line.
Example 2
Input
1 42
Expected
Gold Medal
Explanation
There is only one robot, so it automatically finishes 1st regardless of its score, earning "Gold Medal".
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →