#P7476. 「C.E.L.U-02」苦涩
「C.E.L.U-02」苦涩
Description
In YQH's dream, he saw his past memories constantly surfacing in his mind. These memories brought him overwhelming bitterness. He wants to forcibly forget some of them to reduce his bitterness.
YQH's brain can be divided into sections. Each section is like a multiset that stores memories, and it is initially empty. He will perform operations of the following three types:
Operation 1: In every section in the interval , a memory with bitterness value appears.
Operation 2: YQH starts cleaning the memories in sections . If a section and the maximum bitterness value in section is equal to the maximum bitterness value among all sections , then forget one such memory with the maximum bitterness value in that section. If there are multiple memories with the same maximum bitterness value in the same section, only one is forgotten. If a section has no memory, ignore it.
Operation 3: YQH wants to know the maximum bitterness value of memories among sections . If it does not exist, output -1.
Input Format
The first line contains two numbers, .
The next lines: the first number represents the operation type . For operation 1, there are three numbers . For operation 2 or 3, there are two numbers .
Output Format
For each operation 3, output one line representing the answer.
5 4
1 1 3 2
1 2 4 3
2 3 3
3 1 3
3
6 6
1 1 6 2
1 3 3 2
1 3 4 3
2 3 4
3 3 3
3 4 4
2
2
Hint
Sample Explanation
Sample Explanation 1
Below is the state of YQH's brain after each operation:
After the first operation:
After the second operation:
After the third operation:
The fourth operation queries the maximum value in interval , so the answer is .
Sample Explanation 2
Below is the state of YQH's brain after each operation:
After the first operation:
After the second operation:
After the third operation:
After the fourth operation:
The fifth operation queries the maximum value of section , so the answer is .
The sixth operation queries the maximum value of section , so the answer is .
Constraints
| Subtask | n | m | Special Property |
|---|---|---|---|
| No operation 2. | |||
| In operation 2, . | |||
| In operation 2, . | |||
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号