Judging a programming contest is hard work, with demanding contestants, tedious decisions, and monotonous work. Not to mention the nutritional problems of spending 12 hours with only donuts, pizza, and soda for food. Still, it can be a lot of fun.
Software that automates the judging process is a great help. You are part of a group building better, open source, contest-management software based on modular design.
Your component calculates the scores of programming-contest teams and determines the winner. Given the results from several teams, you must determine the winner.
A team's score has two components:
For each problem solved correctly, the penalty is the time at which the problem was solved plus 20 minutes for every incorrect submission on that problem. Problems that are never solved add no penalty points.
For example, if a team solves problem 1 on their second submission at 20 minutes, they are charged $20 + 20 = 40$ penalty points. If they submit problem 2 three times but never solve it, they are charged no penalty points. If they submit problem 3 once and solve it at 120 minutes, they are charged 120 penalty points. Their total score is 2 problems solved with 160 penalty points.
The winner is the team that solves the most problems. If several teams solve the same greatest number of problems, the winner is the one with the fewest penalty points.
The contest has four problems. The input is guaranteed not to produce a tie between teams after penalty points are counted.
| Line | Contents |
|---|---|
| Line 1 | The number of teams, nTeams. |
| Lines 2 … nTeams+1 | Name p1Sub p1Time p2Sub p2Time p3Sub p3Time p4Sub p4Time |
The first element on each team line is the team name, which contains no whitespace. Following it, for each of the four problems, are two integers: the number of runs the team submitted for that problem and the time at which it was solved correctly. If a team did not solve a problem, that time is 0. The number of submissions is at least one whenever the problem was solved.
Output a single line with the name of the winning team, the number of problems it solved, and its penalty points, separated by single spaces.