Basketball
Time limit1sMemory limit1024 MB
Given a log of score changes in two hoops, find the player who scored the most points and report that total.
- Level
Easy2 of 10
- Topics
- Hash map, Implementation, String
- Solved
- No attempts yet
Problem
In Westeros there is a game that looks a lot like basketball. Tyrion Lannister cannot play it, but he enjoys following the game.
Westeros basketball is played by people. There are two hoops. Each player can shoot into either hoop and score one, two, or three points. Tyrion keeps a log. Each line records how the score changed and who made the basket. The score is two numbers, the points in the first hoop and the points in the second hoop, separated by a colon. A line in Tyrion's log can look like <<30:41 Lannister>>.
After the game, Tyrion wants to know who scored the most points. Managing the money of the realm takes most of his time, so he asks for help. The Lannisters always pay their debts, and you have every reason to help him.
Input
The first line contains the number of players ().
Each of the next lines contains a player name (). Names consist only of uppercase and lowercase Latin letters.
The line numbered contains the number of Tyrion's records ().
Each of the next lines has the form <<: >>, without the angle brackets. Here is the points in the first hoop, is the points in the second hoop, and is the name of the player who made that score. Tyrion never miscounts, so every record is correct.
The starting score is 0:0.
Output
Print one line with the name of the player who scored the most points and the number of points that player scored. If several players are tied, print any of them.