#K48777. Scoreboard Update

    ID: 28496 Type: Default 1000ms 256MiB

Scoreboard Update

Scoreboard Update

In this problem, you are given the number of participants (p), the number of problems (q), and a series of submission records. Each problem has a point value (difficulty). Each submission record contains four values: participant ID, problem ID, submission time, and status (which can be either "correct" or "incorrect").

For each participant, compute the total score as the sum of the difficulties of the problems they solved correctly (only the first correct submission for each problem is counted). Also, record the earliest submission time among their correct submissions. If a participant has no correct submissions, consider the earliest correct submission time as 0.

The final scoreboard should be sorted according to the following criteria:

  1. Descending order of total score.
  2. If total scores are equal, ascending order of the earliest correct submission time (note: a missing correct submission is considered as 0, which ranks lower than any positive time).
  3. If still tied, ascending order of participant ID.

Your task is to update and display the scoreboard based on the input submissions.

inputFormat

Input is read from standard input (stdin). The first line contains three integers (p), (q), and (n): the number of participants, the number of problems, and the number of submissions, respectively. The second line contains (q) integers representing the difficulty (points) for each problem. The following (n) lines describe each submission with four values separated by spaces: participant_id, problem_id, submission_time, and status (either "correct" or "incorrect").

outputFormat

Output to standard output (stdout) exactly (p) lines, each containing three integers: participant_id, total_score, and earliest_correct_submission_time. The scoreboard must be sorted first by total score in descending order, then by earliest correct submission time in ascending order (with 0 indicating no correct submissions), and finally by participant_id in ascending order.## sample

3 3 6
500 300 200
1 1 30 correct
2 2 45 correct
3 3 50 correct
1 1 60 incorrect
2 2 70 incorrect
3 3 75 correct
1 500 30

2 300 45 3 200 50

</p>