#P4314. CPU 监控
CPU 监控
Description
Bob needs a program to monitor CPU usage. This is a tedious task. To make it simpler, Bob will gradually list what he will do today while using the computer.
Bob does many things. Besides running brute-force programs and watching videos, he also goes out to play, randomly clicks the mouse, and might even kick out the power cord. Some actions increase or decrease the CPU usage by a value during the time they are performed; some actions directly set the CPU usage to a specific value.
Of course, Bob will ask: under the influence of the previously listed events, what is the maximum CPU usage in a certain time interval. Sometimes Bob will also curiously ask: in a certain time interval, what is the highest CPU usage that has ever been reached.
To be precise, usage is represented by an integer instead of a percentage.
It is not guaranteed that Bob's event list is free of weird issues that could make the usage negative...
Description
Input Format
The first line contains a positive integer , the total time Bob needs to monitor the CPU.
The second line contains numbers indicating, before your monitoring program starts, the CPU usage that has already been reached at each moment within this time span.
The third line contains an integer , the total number of actions and queries Bob will perform.
Each of the next lines is either a query or an event:
Q X Y: Query the maximum current CPU usage from to (under the effects of all events listed so far).A X Y: Query the highest CPU usage that has ever been reached from to (over the entire history up to now).P X Y Z: List an event that increases the CPU usage by from to .C X Y Z: List an event that sets the CPU usage to from to .
Time is measured in seconds, and usage has no unit.
and are positive integers (), and is an integer.
The interval from to is inclusive of second and second .
It is guaranteed that all necessary operations fit within 32-bit signed integers.
Output Format
For each query, output one integer on its own line as the answer.
10
-62 -83 -9 -70 79 -78 -31 40 -18 -5
20
A 2 7
A 4 4
Q 4 4
P 2 2 -74
P 7 9 -71
P 7 10 -8
A 10 10
A 5 9
C 1 8 10
Q 6 6
Q 8 10
A 1 7
P 9 9 96
A 5 5
P 8 10 -53
P 6 6 5
A 10 10
A 4 4
Q 1 5
P 4 9 -69
79
-70
-70
-5
79
10
10
79
79
-5
10
10
Hint
The testdata is distributed as follows:
- In testdata 1 and 2, and are both at most .
- In testdata 3 and 4, there are only
Qqueries. - In testdata 5 and 6, there are only
Cevents. - In testdata 7 and 8, there are only
Pevents.
For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号