TLE '15 P1 - Power Rankings

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type

The Trudeau Computer Science Club is famous in Pierre Elliott Trudeau High School for having the best computer scientists in the whole school present in one room. Every week, ZQFMGB12 lectures his dedicated pupils (with PowerPoint) on some cool computer science concept in hopes that they will do well on the CCC.

Unfortunately, it is nearing the time to write power rankings! The power rankings are a ranking of Trudeau computer scientists. Obviously, d and ZQFMGB12 are at the top, so ZQFMGB12 doesn't have to worry about where to place those two.

However, the other students in the Trudeau Computer Science Club have barely written any contests and as a result, it can be hard to rank them properly. Instead, ZQFMGB12 checks their progress on online judges to see how many homework problems they have completed, but that didn't help either since they barely even looked at the homework.

As a last resort, ZQFMGB12 hid secret cameras around their houses to find out how many minutes they spent reviewing his PowerPoints. As controversial as this technique is, ZQFMGB12 is now able to see how dedicated his students are.

He decides that the greater the total time a student spends on his PowerPoints, the better the ranking that student should receive. Specifically, the ranking of a student is 3 plus the number of students with a greater total time. It is guaranteed that no two students have the same total time.

However, ZQFMGB12 has a computer science project due in June and he needs your help in determining the power rankings.

Given the names of ZQFMGB12's N students and how long each student spends on each of his P PowerPoints, can you determine the power rankings?

Input Specification

The first line of input will contain N (1 \le N \le 100) and P (1 \le P \le 100).

The next N lines will contain the names of ZQFMGB12's students. Names are unique, will not exceed 50 characters, and will only contain printable non-whitespace ASCII characters.

The next P lines will contain N space-separated integers; the j^\text{th} integer on line i specifies the amount of time (in minutes) the j^\text{th} student spent on the i^\text{th} PowerPoint. No student spends a negative number of minutes studying, nor more than 1\,000 minutes on a single PowerPoint.

Output Specification

On separate lines, from the best rank (lower number) to the worst rank (higher number), output the rank, followed by a period and a single space, and the name of the student with that rank.

Sample Input

5 3
3 4 2 1 0
1 3 4 2 0
5 1 7 4 0

Sample Output

3. Nathanl3
4. EnochPoon
5. LiuJason
6. AlexW
7. TT1103


  • 1
    ChaSiu  commented on March 11, 2016, 8:22 p.m. edited

    Nah... I'm too lazy to do your homework.

    • 2
      Robloxian  commented on Dec. 7, 2018, 9:58 p.m. edited

      But you still spent time on the powerpoints