#P2201. 数列编辑器
数列编辑器
Description
Xiao Z is an elementary school student who loves math. Recently, he has been studying properties of integer sequences.
To facilitate his research, Xiao Z wants to implement a sequence editor called "Open Continuous Lines Processor".
At the beginning, the sequence editor contains no numbers, only a cursor. This sequence editor needs to support five operations.
I xInsert the number immediately before the cursor.DDelete the number immediately before the cursor.LMove the cursor one position to the left.RMove the cursor one position to the right.Q kLet the sequence before the cursor be . Output the maximum prefix sum among the first positions, i.e., . It is guaranteed that .
Input Format
The first line contains an integer , indicating the number of operations.
Then follow lines, each containing one command.
Output Format
For each Q k command, output an integer representing the answer to that operation.
8
I 2
I -1
I 1
Q 3
L
D
R
Q 2
2
3
Hint
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, , and the absolute value of each inserted number does not exceed .
It is guaranteed that the D operation will not be performed when the sequence editor is empty.
Translated by ChatGPT 5
京公网安备 11011102002149号