Problem 4: Programming Contests
Background
Scoring a programming contest is fairly straightforward.
For every correct submission, a team is given a score
equal to the number of minutes it took that team to
get the problem right. For every incorrect submission,
a team is given a 20 minute penalty. The penalty
is added to the teams score only if the team
gets the problem correct. If a team submits a correct
solution, then later on accidentally submits it
again, they are assigned the later score. The first
correct submission is ignored (ie, no penalty is
assigned for the first submission.) if a team submits
a correct solution, then later on submits an incorrect
solution for the same problem, the first submission is
also ignored. The winner of a contest is the team
with the most problems solved. If two or more
teams have the same number of problems solved,
add up their scores + penalties. The team with the lowest
score wins.
Input:
The first line of input will contain a single number, N, between
2 and 20. This is the number of teams in the contest.
The next N lines are the team names. Team names will
be no more than 20 characters long. Team numbers are
assigned sequentially. So the first team is team #1, the second
team #2, etc. After that will be any number of lines representing
submissions. Each line will be of the form:
team_number problem status time
where team_number is the team number assigned to a team.
problem is the problem number. status is one
letter, either c (the submission is correct) or i (the submission
is incorrect), and time is the time in minutes
that the submission occured.
There will be exactly 6 problems on the contest (although,
not all problems may get solved by a team).
Output:
Your program is to print the results of the contest in the form
place team_name problems score
where place is the rank of the team in the standings.
team_name is the team name, problems is the
number of correct problems the team solved, and score
is the total score of the team.
The rank of a team will be unique (ie, you will not be given
a submission set where two teams have the same number of problems
and same score).
Sample Input
4
walrus
carpenter
red
vtech
3 1 c 3
3 3 c 10
1 1 i 12
2 1 c 13
1 1 c 15
3 2 c 17
2 1 i 20
3 6 c 25
1 3 c 35
3 4 c 35
2 2 c 45
3 5 c 45
2 5 c 55
Sample Output
1 red 6 135
2 walrus 2 70
3 carpenter 2 100
4 vtech 0 0