#P8157. 「PMOI-5」肥宅快乐水

「PMOI-5」肥宅快乐水

Background

When lhm was drinking Fat Nerd Happy Water, he came up with this idea, so he named it Fat Nerd Happy Water.

This problem is a weakened version. Please look forward to the strengthened version in Ynoi.

Special thanks: the verifier, Dual-Tube Fluorescent Lamp, crushed this problem’s std.

Problem Description

lhm has a polygon formed by nn rectangles of width 11 arranged horizontally. The height of the ii-th rectangle is aia_i. Now he will perform kk operations. In each operation, the height of one rectangle of width 11 is decreased by 11. After each operation, find the maximum area of a sub-rectangle (obviously, the sub-rectangle must be a continuous segment).

Note that in all cases, the height is always ≥0\geq 0.

Since lhm is too weak, he wants to ask the smart you to help him solve it.

Input Format

The input has a total of k+2k + 2 lines.
The first line contains two integers n,kn, k, with meanings as described above.
The second line contains nn integers aia_i, where the ii-th integer represents the height of the ii-th rectangle.
The next kk lines each contain one integer id⁡′\operatorname{id}'. The operation index is $\operatorname{id}=\operatorname{id}'\bigoplus \operatorname{lastans}$, where lastans⁡\operatorname{lastans} is the answer to the previous query, and initially lastans⁡=0\operatorname{lastans}=0.

Output Format

The output has a total of kk lines.
Each line contains one integer, which is the required answer for each query.

5 2
2 3 1 3 2
2
6
5
4

Hint

This problem uses bundled testdata.

Subtask ID Score n,kn, k
1 10 ≤500\leq 500
2 ≤5000\leq 5000
3 40 ≤105\leq 10^5
4 ≤5×105\leq 5\times10^5

For 100%100\% of the data, 1≤n,k≤5×1051\le n,k\le 5\times 10^5, 1≤ai≤1091\leq a_i\leq 10^9. It is guaranteed that id⁡′\operatorname{id}' is within the range of long long.

Translated by ChatGPT 5