#P4118. [Ynoi2018] 末日时在做什么?有没有空?可以来拯救吗?

    ID: 3052 远端评测题 1000ms 64MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>2018O2优化块状链表,块状数组,分块Ynoi

[Ynoi2018] 末日时在做什么?有没有空?可以来拯救吗?

Description

Chtholly gives you a sequence aa of length nn, and there are mm operations.

  1. Add xx to all numbers in the interval [l,r][l, r].
  2. Query the maximum subarray sum in the interval [l,r][l, r], where choosing no elements is allowed.

Input Format

The first line contains two integers n,mn, m. The second line contains nn integers representing the sequence aa. The following mm lines:

  • 1 l r x: add xx to all numbers in the interval [l,r][l, r].
  • 2 l r: query the maximum subarray sum in the interval [l,r][l, r], with the empty subarray allowed.

Output Format

For each query, output one number representing the answer.

5 5
-2 -3 -3 -3 -3
2 1 5
1 2 4 4
2 1 5
1 2 3 1
2 3 3
0
3
2
5 5
-2 3 3 -3 3
2 1 5
1 2 4 -4
2 1 5
1 2 3 1
2 3 3
6
3
0

Hint

Idea: nzhtl1477, Solution: ccz181078, Code: nzhtl1477 & ccz181078 & mrsrz, Data: nzhtl1477 & mrsrz & w33z8kqrqk8zzzx33.

1n,m1051 \le n , m \le 10^5, ai109| a_i | \leq 10^9, x109|x|\leq 10^9.

It is guaranteed that at any time ai2×109|a_i|\leq 2\times 10^9.

By nzhtl1477 & ccz181078.

Translated by ChatGPT 5