#P11101. [ROI 2022] 天狼星探险队 (Day 2)
[ROI 2022] 天狼星探险队 (Day 2)
Background
Translated from ROI 2022 D2T2.
In the game “Sirius Expedition Team”, there are players, numbered from to . Each player has accumulated experience points from previous missions. If two players have the same experience value, we say they are at the same level. A player with higher experience has a higher level.
The game consists of multiple rounds. At the end of each round, every player gains experience equal to the number of distinct higher levels among the other players. For example, if the players’ experience values are , then the first player’s experience increases by : there are two higher levels—players with experience and . In this example, the last player’s experience does not increase. All players’ experience changes simultaneously; for this example, at the end of the round the experience becomes .
Problem Description
You need to answer several queries. Each query is one of the following three types:
- After rounds, how many distinct levels will the players have?
- During the first rounds, how much total experience is added across all players?
- At the end of the -th round, how much experience will player have?
Input Format
The first line contains two integers and (), representing the number of players and the number of queries.
The second line contains integers (), representing each player’s experience at the start of the game.
The next lines contain the queries. Each line starts with an integer (), representing the query type.
- If , it is followed by an integer (), the number of rounds.
- If , it is followed by an integer (), the number of rounds.
- If , it is followed by two integers and (), the number of rounds and the player index.
In all queries, refers to the time at the start of the game, before the first round.
Output Format
For each query, output one number per line as the answer.
6 6
5 4 4 2 2 2
1 0
1 1
1 2
2 1
2 2
3 1 5
3
2
1
8
11
4
5 4
0 3 5 4 2
1 0
1 1
2 1
3 1 1
5
2
10
4
Hint
The figure below shows how the players’ experience values change during the game in the two samples.

All Constraints are given in the Input Format.
| Subtask | Score | ||||
|---|---|---|---|---|---|
Translated by ChatGPT 5