ACM Rank Table
Time limit2sMemory limit128 MB
Aggregate each team's runs under ACM penalty rules, then sort teams by solved count, total time, and team number.
- Level
Easy3 of 10
- Topics
- Sorting, Implementation, Hash map
- Solved
- No attempts yet
Problem
An ACM-style programming contest is run by judging software that accepts and evaluates each team's submissions (called runs) and shows the standings in a rank table. The scoring rules are:
- Every run is either accepted or rejected.
- A team solves a problem if at least one of its runs for that problem is accepted.
- For a solved problem, the time consumed is the time from the start of the contest to the team's first accepted run for that problem, plus a 20-minute penalty for every earlier run the team made on the same problem before that accepted run. An unsolved problem consumes no time.
- A team's total time is the sum of the time consumed over every problem it solved.
- Teams are ranked first by the number of solved problems (more solved is better); ties are broken by the smaller total time.
- Although the time is shown in minutes, it is measured to a precision of one second, and the seconds are taken into account when ranking teams.
- Teams that remain tied after the rules above are ordered by increasing team number.
Given the list of runs, each with its submission time and result, produce the rank table for the teams.
Input
The input begins with two integers and . Then follow runs, each given as four integers :
- — the team number,
- — the problem number,
- — the submission time in seconds from the start of the contest,
- — if the run was accepted, otherwise.
The numbers may be separated by spaces or line breaks.
Output
Print the team numbers on a single line, separated by single spaces, ordered from the best rank to the worst.