#P9993. [Ynoi Easy Round 2024] TEST_133

[Ynoi Easy Round 2024] TEST_133

Background

Please do not abuse the judging system of this problem. If you abuse it, your account will be banned.

Problem Description

Given a sequence a1,,ana_1, \dots, a_n, there are mm operations:

  • Modify operation: given l,r,xl, r, x, increase the values of al,al+1,,ara_l, a_{l+1}, \dots, a_r by xx.
  • Query operation: given l,r,xl, r, x, ask for the maximum, among all indices ii satisfying lirl \le i \le r and ai<xa_i < x, of the historical maximum value of aia_i (i.e., the maximum among its initial value and its values after each modify operation).

Input Format

The first line contains two integers n,mn, m.

The next line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n.

The next mm lines each contain four integers o,l,r,xo, l, r, x, where o=1o = 1 denotes a modify operation, and o=2o = 2 denotes a query operation.

Output Format

For each query operation, output one line with the answer (in particular, if there is no index ii that satisfies the condition, output -inf).

5 10
-53 36 41 55 77
1 1 1 10
2 4 4 79
2 3 3 -28
1 1 5 -29
1 1 3 27
2 2 5 88
2 2 3 24
1 2 2 10
1 1 3 -9
1 2 5 -10
55
-inf
77
-inf

Hint

Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078.

For 0%0\% of the testdata, n,m5000n, m \le 5000.

For another 1/3%1/3\% of the testdata, the query operations guarantee l=1l = 1 and r=nr = n.

For another 1/31/3 of the testdata, there are no modify operations.

For 100%100\% of the testdata, 1n,m5×1051 \le n, m \le 5 \times 10^5, ai109|a_i| \le 10^9 (only the initially given sequence guarantees this limit), 1lrn1 \le l \le r \le n, and x109|x| \le 10^9.

Translated by ChatGPT 5