Final Standings

WishingBone is quite familiar with rules of contest ranking. It states:

Teams are ranked by the number of problems solved in descending order;

Teams that solved the same number of problems are ranked by total penalty time in ascending order;

Teams that have the same rank are listed by team id in lexicographic order, which should be case-insensitive.

Additionally,

A problem is solved only when the team has submitted an accepted run.

Penalty time for a problem is the sum of the elapsed time of the first accepted run and twenty minutes for each previous run of this problem.

Total penalty time is the sum of penalty time for all the problems solved.

Only teams solved at least one problem will be listed on the final standing.

You are requested to generate this final standing.

Input

The first line of input is a positive integer N (N <= 100), which is the number of problems of this contest.

Each line of input represents one run in the form

Elapsed Time Team ID Problem ID Judge Reply

where Elapsed Time is the time from the start of the contest (in minute); Team ID is a string of no more than 30 upper and lower Latin characters; Problem ID is an integer from 1 to N; Judge Reply is one of AC, PE, CE, RE, TLE, MLE and OLE. Elasped Time will be in ascending order. The number of teams will not exceed 10000.

Output

Print one team on each line in the form

Rank Team ID Problems Solved Total Penalty Time

the first three of which should be left-justified in fields of 10, 30 and 10.

Refer to sample output for more details.

Sample Input

3
30 Fatmouse 1 WA
32 Killer 2 AC
39 Turing 3 RE
56 Fatmouse 2 CE
63 Turing 3 AC
77 Killer 1 PE
79 Killer 1 AC
83 ZzZzZ 3 AC
89 Fatmouse 3 OLE
89 Chenyue 3 AC

Sample Output

1 Killer 2 131
2 Turing 1 83
ZzZzZ 1 83
4 Chenyue 1 89

3个回答

你的这个问题很难去回答

这个问题看上去很并不是很难回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐