LCC/Moose '19 Contest 3 J2 - Tricky Totals

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

It's been a month and LCC is back at it again! To celebrate this contest happening again, Larry wants to find out the top 2 results from last year's contest. However, since there were 5 different contests last year, Larry has to add all of them up to see who had the best total score.

Since Larry is too lazy to do the addition to add up all of the scores, he has decided to make you do it for him.

Input Specification

The first line will contain an Integer N (2 \leq N \leq 100), the number of teams Larry is comparing.

The next N lines will first contain a string between 1 to 10 characters, the name of the LCC team, and then 5 integers a, b, c, d, and e, (0 \leq a, b, c, d, e \leq 700), each being the team's score for one of the 5 LCC's. The string is guaranteed to only contain letters from a to z.

Output Specification

On the first line, print the name of the LCC team with the highest total score, along with their score, separated by a space. If two teams have the same score, the lexicographically least has the higher priority.

On the second line, print the name of the LCC team with the second highest total score, along with their score, separated by a space.

Sample Input 1

3
a 6 10 9 4 20
b 7 9 5 18 19
c 0 17 16 5 15

Sample Output 1

b 58
c 53

Sample Input 2

4
hewmatt 120 150 100 100 100
hewmattt 100 90 110 130 140
bot 100 100 100 100 100
a 90 100 90 100 90

Sample Output 2

hewmatt 570
hewmattt 570

Explanation for Sample Output 2

Even though they have the same score, "hewmatt" is lexicographically smaller than "hewmattt" so "hewmatt" is first.


Comments

There are no comments at the moment.