#P2496. [SDOI2012] 体育课
[SDOI2012] 体育课
Description
It is time for another PE class. There are students standing in a row. They all dislike the student at the first position. For any student behind the first one, if they are taller than the first student, they gain a happiness value equal to their height minus the height of the first student. If a student is shorter than the first student, their happiness value is .
Now the PE teacher comes with magical powers and can perform the following three operations:
- Query the maximum happiness value within a given interval.
- Swap two students.
- Select an interval and add to the first person in the interval, to the second, to the third, and so on.
However, the teacher cannot count well, so he asks you to answer each query.
For clarity, for an interval , define the happiness of position () as . Operation asks for the maximum of these values over .
Input Format
The first line contains two integers , the number of students and the number of operations.
The second line contains integers, the heights of the students in order.
Each of the following lines starts with an integer indicating the operation:
- If , then two integers follow, asking for the maximum happiness value in interval as defined above.
- If , then two integers follow, indicating to swap the students at positions and .
- If , then three integers follow, indicating that for every with , add to .
Output Format
For each query, output the answer to every operation in order.
6 7
109 827 100 530 10 826
3 1 6 1
2 2 6
1 2 4
1 2 3
2 2 6
1 2 6
1 2 5
722
722
722
719
Hint
Constraints
- For of the testdata, .
- Additionally, in of the testdata, there is no operation .
- Additionally, in of the testdata, there is no operation .
- For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号