#P6792. [SNOI2020] 区间和
[SNOI2020] 区间和
Description
There is an integer sequence of length (it may contain negative numbers). Now perform operations on it. Each operation is one of the following:
0 l r xmeans for , assign to ;1 l rasks for the maximum subarray sum in the interval , i.e. $\max(0, \max_{l\le u\le v\le r} (\sum_{i=u}^v a_i))$.
Input Format
The first line contains two positive integers , representing the sequence length and the number of operations.
The second line contains positive integers , representing the initial sequence.
The next lines each are in the form 0 l r x or 1 l r, representing one operation.
Output Format
For each operation of the form 1 l r, output one integer per line, representing the answer.
5 7
2 -4 6 -5 5
1 1 5
0 1 5 -4
1 1 5
0 3 4 -1
1 1 5
0 1 3 -1
1 1 5
6
7
10
11
Hint
Sample Explanation
For sample :
- At the 1st query, the sequence is , and the maximum subarray sum is .
- At the 2nd query, the sequence is , and the maximum subarray sum is .
- At the 3rd query, the sequence is , and the maximum subarray sum is .
- At the 4th query, the sequence is , and the maximum subarray sum is .
Constraints
For all testdata, , , .
- For of the testdata, .
- For another of the testdata, .
- For another of the testdata, each operation satisfies (i.e. only point updates).
- For another of the testdata, each operation satisfies (i.e. only global queries).
- For the remaining of the testdata, there are no special constraints.
There are 3 hack testdata points from the problem setter.
Translated by ChatGPT 5
京公网安备 11011102002149号