Rank every athlete by summing only their M highest weighted place points, breaking ties alphabetically with skipped ranks.
Easy3SortingHash mapSimulationInterviewNo attempts yetTime limit5sMemory limit512 MBThe world has many strong athletes, and it is hard to say who is the best at a sport when different athletes win different competitions. Here is one way to rank them.
You are given the points per place, the weight of each competition, and the results of the competitions. Rank every athlete who appears in the input.
The first line holds the number of test cases T. T test cases follow, each of them made of:
For each test case, first print one line holding Case #x:, where x is the test case number starting from 1. Then print every athlete that appears in the input, one per line, in the format r: name, where r is the athlete's rank and name is the athlete's name.
An athlete's rank is one plus the number of athletes with a strictly larger total. Athletes with equal totals therefore share a rank, and the next rank after them skips by the size of the tied group. Print higher ranks first, and print athletes of the same rank in alphabetical order of their names. Do not print a blank line between test cases.
A through Z and is at most 10 characters long.In the first example BOLT scored 7000 across his two competitions and ranks 1st. GAY would have 8500 if all four competitions counted, but only the top two count, so GAY has 6500 and ranks 2nd. PEIMENG and TIANBING both have 1500, so they share rank 3 and are listed alphabetically. Two athletes share rank 3, so the next rank is 5 rather than 4, and LARRY with 1000 points ranks 5th.