# Range Chmin Chmax Add Range Sum

AC一覧

## Problem Statement問題文

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$

• 0 $l$ $r$ $b$: $i = l, \dots, {r-1}$ のそれぞれについて $a_i \gets \min(a_i, b)$
• 1 $l$ $r$ $b$: $i = l, \dots, {r-1}$ のそれぞれについて $a_i \gets \max(a_i, b)$
• 2 $l$ $r$ $b$: $i = l, \dots, {r-1}$ のそれぞれについて $a_i \gets a_i + b$
• 3 $l$ $r$: $\sum _ {i = l} ^ {r-1} a_i$ を出力

## Constraints制約

• $1 \leq N, Q \leq 200{,}000$
• $\vert a_i \vert \leq 10^{12}$ is satisfied always while processing queries.
クエリ処理の過程で常に $\vert a_i \vert \leq 10^{12}$ が成り立つ
• $0 \leq l < r \leq N$

## Input入力

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


### # 1

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

15
106
119
147


Timelimit: 10 secs

Before submitting, please confirm terms and conditions