Process the team's submission log in order and report the number of solved problems and the total penalty including 20 minutes per prior wrong attempt.
Easy3SimulationHash mapInterviewNo attempts yetTime limit1sMemory limit256 MBThe contest scoring program reads one team's submission log in chronological order and reports the result. Each log line holds the submission time, the problem name, and the verdict, which is a pass or a failure.
Teams are ranked by the number of solved problems first. When two teams solve the same number of problems, the smaller penalty comes first. Penalty counts only for solved problems. The penalty of a solved problem is the minute of its accepted submission plus 20 times the number of failed submissions the team made on that problem, and the team penalty is the sum of the penalties of all solved problems. A team that solves nothing has penalty 0. Failed submissions on a problem the team never solves add nothing.
Contest rules say that once a team solves a problem, every later submission to that problem is ignored, so it never appears in the log. Submission times are recorded in whole minutes, so several submissions can share one minute. The submissions themselves happened in order, so when the same problem appears on more than one line at the same minute, every one of those lines except the last is a failure.
Read the log and report how many problems the team solved and the team penalty.
The log is given in n lines. (0≤n≤100)
Each line holds three values separated by spaces: an integer m for the submission time, then the problem name, then the verdict. (0≤m≤300, the problem name consists of uppercase letters, and the verdict is right or wrong.)
Submission times are given in non-decreasing order, and several lines can carry the same time.
A line holding the single integer −1 follows the last log line.
Print the number of solved problems and the total time including penalty on one line, separated by a space.