#P3863. 序列

    ID: 2792 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>洛谷原创O2优化排序期望块状链表,块状数组,分块洛谷月赛

序列

Description

Given a sequence of length nn, there are qq operations of the following forms.

1 l r x1~l~r~x means adding xx to each element with index in [l,r][l,r] (note that xx may be negative).

2 p y2~p~y means querying for how many seconds in the past apa_p has been at least yy (excluding the current second; see the sample for details).

Time starts at second 00, and the ii-th operation occurs at second ii.

Input Format

The first line contains two integers n,qn,q, as described.

The second line contains nn integers aia_i, the initial values of the sequence.

Each of the next qq lines starts with opt\text{opt}, indicating the type of this operation. If opt=1\text{opt} = 1, it is followed by three integers l,r,xl, r, x, as described. If opt=2\text{opt} = 2, it is followed by two integers p,yp, y, as described.

Output Format

For each operation of type 22, output one integer on a single line indicating the answer.

3 3
1 3 5
2 1 2
1 1 2 -3
2 1 1
0
2

Hint

Explanation for Sample 1: at position 11, the values from second 00 to second 33 are 1,1,2,21,1,-2,-2. For the first query, during seconds 00 to 11=01-1=0, the value is not less than 22. For the second query, during seconds 00 to 31=23-1=2, the value is not less than 11, namely at second 00 and second 11.

For 30%30\% of the testdata, n,q1000n,q \leq 1000.

For 70%70\% of the testdata, n,q50000n,q \leq 50000.

For 100%100\% of the testdata, 2n,q1000002 \leq n,q \leq 100000, 1lrn1 \leq l \leq r \leq n, 1pn1 \leq p \leq n, 109x,y,ai109-10^9 \leq x,y,a_i \leq 10^9.

Translated by ChatGPT 5