#C4296. Leaderboard Maintenance
Leaderboard Maintenance
Leaderboard Maintenance
A gaming company wants to track high scores in its games. Each game has a leaderboard that maintains the top \(m\) scores. Initially, all leaderboards are empty. The system must support two types of queries:
- 1 g s: A player scores \(s\) points in game \(g\). The system should update game \(g\)'s leaderboard by including \(s\) if and only if it qualifies to be among the top \(m\) scores.
- 2 g: Output the current leaderboard for game \(g\) by printing the scores in non-increasing order. If there are fewer than \(m\) scores, print all the scores in non-increasing order.
Note: For a query of type 1, if the leaderboard already has \(m\) scores, then the new score \(s\) replaces the smallest score in the leaderboard if \(s\) is greater than that minimum value.
Input and Output requirements: The input is read from standard input and the output should be written to standard output.
inputFormat
The first line contains two integers \(n\) and \(m\), where \(n\) is the number of games and \(m\) is the maximum number of top scores maintained in each game's leaderboard.
The second line contains a single integer \(q\), representing the number of queries.
Each of the next \(q\) lines contains a query in one of the following formats:
- 1 g s: A player scores \(s\) points in game \(g\).
- 2 g: Print the leaderboard for game \(g\) in non-increasing order.
outputFormat
For each query of type "2 g", output a single line containing the scores of game \(g\)'s leaderboard in non-increasing order, separated by a single space.
## sample3 2
7
1 1 50
1 1 60
2 1
1 2 40
1 1 70
2 1
2 2
60 50
70 60
40
</p>