luogu#P9877. [EC Final 2021] Vacation

[EC Final 2021] Vacation

题目描述

Prof. Pang has an annual leave of cc days and he wants to go on vacation.

Now there are nn days in a year. Prof. Pang can gain aia_i happiness if he rests on the ii-th day. The values of happiness, aia_i, may be negative.

Prof. Pang wants you to do mm operations:

  • 1 x y1~x~y, change the happiness of the xx-th day to yy.
  • 2 l r2~l~r, Prof. Pang wants to find a period of vacation in [l,r][l, r]. He wants to rest for several (possibly 00) days in a row and gain as much happiness as possible. However, he only has cc days off, thus he can rest for no more than cc consecutive days in [l,r][l,r].

That means he wants to find

$$\max\left(\max_{l \leq l' \leq r' \leq r\atop r'-l'+1\leq c} ~~ \left(\sum_{i=l'} ^{r'} a_i\right), 0\right). $$

输入格式

The first line contains three integers $n, m, c (1\leq n\leq 2\times 10^5, 1\leq m \leq 5\times 10^5, 1\leq c\leq n)$ indicating the number of days in a year, the number of operations, and Prof. Pang's annual leave days.

The next line contains nn integers a1,a2,,an(109ai109)a_1, a_2, \dots, a_n(-10^9 \leq a_i\leq 10^9) indicating the values of happiness of every day.

The next mm lines are the mm operations in the format described above.

It is guaranteed that $1\leq x\leq n, -10^9\leq y\leq 10^9, 1\leq l\leq r \leq n$.

输出格式

For each operation of the second type, print the answer.

题目大意

连续的 nn 天,每天的 HappinessHappinessaia_i 。包含 mm 次操作,和一个 cc

  • 1.1.axa_x 的值改为 yy
  • 2.2. 询问 [l,r][l,r] 内,连续 tt 天内,最大的 HappinessHappiness 值的和,其中 t[0,c]t∈[0,c]
5 6 3
0 -5 -3 8 -3
2 3 5
1 2 5
2 1 5
1 4 -3
2 3 5
2 1 5
8
10
0
5