P13977 Introduction to Sequence Block Decomposition 2
Background
The constraints of the testdata in Luogu's "Introduction to Sequence Block Decomposition" series differ from those of the original problems.
Description
You are given a sequence of length $n$ and $n$ operations. The operations involve range addition and queries for the number of elements smaller than a value $x$ in a range.
Input Format
The first line contains one integer $n$.
The second line contains $n$ integers, where the $i$-th integer is $a_i$, separated by spaces.
Then $n$ lines follow, each containing a query. Each line contains four integers $\mathrm{opt}$, $l$, $r$, $c$, separated by spaces.
If $\mathrm{opt} = 0$, it means that $c$ is added to every number in $[l, r]$.
If $\mathrm{opt} = 1$, it means that you should query the number of elements in $[l, r]$ that are smaller than $x = c^2$.
Output Format
For each query, output one integer on a single line giving the answer.
Explanation/Hint
### Subtasks
Subtask 1 (40 points): $1 \leq n \leq 50000$, $-2^{31} \leq a_i, c, \mathrm{ans} \leq 2^{31}-1$.
Subtask 2 (60 points): $1 \leq n \leq 200000$, $-2^{31} \leq a_i, c, \mathrm{ans} \leq 2^{31}-1$.
For all testdata, $1 \leq n \leq 200000$ and $-2^{31} \leq a_i, c, \mathrm{ans} \leq 2^{31}-1$. $\mathrm{opt} \in \{0,1\}$. The testdata do **not** guarantee that every $a_i$ satisfies $-2^{31} \leq a_i \leq 2^{31}-1$ after each operation. $1 \leq l \leq r \leq n$.
Translated by QwenWork