Problem8827--[yosupo] Data Structure - Range Chmin Chmax Add Range Sum

8827: [yosupo] Data Structure - Range Chmin Chmax Add Range Sum

[Creator : ]
Time Limit : 1.500 sec  Memory Limit : 512 MiB

Description

Given a size $N$ interger sequence $a_0, a_1, \dots, a _ {N - 1}$. Process the following $Q$ queries in order:

- 0 $l$ $r$ $b$: For each $i = l, \dots, {r-1}$, $a_i \gets \min(a_i, b)$
- 1 $l$ $r$ $b$: For each $i = l, \dots, {r-1}$, $a_i \gets \max(a_i, b)$
- 2 $l$ $r$ $b$: For each $i = l, \dots, {r-1}$, $a_i \gets a_i + b$
- 3 $l$ $r$: Print $\sum _ {i = l} ^ {r-1} a_i$

Input

$N$ $Q$
$a_0$ $a_1$ ... $a_{N - 1}$
$\textrm{Query}_0$
$\textrm{Query}_1$
:
$\textrm{Query}_{Q - 1}$

Constraints

$1 \leq N, Q \leq 200000$
$\vert a_i \vert \leq 10^{12}$ is satisfied always while processing queries.
$0 \leq l < r \leq N$

Sample 1 Input

5 7
1 2 3 4 5
3 0 5
2 2 4 100
3 0 3
0 1 3 10
3 2 5
1 2 5 20
3 0 5

Sample 1 Output

15
106
119
147

HINT

相同题目:yosupo

Source/Category