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

「PMOI-5」肥宅快乐水

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, 1n,k5×1051\le n,k\le 5\times 10^5, 1ai1091\leq a_i\leq 10^9. It is guaranteed that id\operatorname{id}' is within the range of long long.

Translated by ChatGPT 5