P10639 BZOJ4695 The Most Fake Female Contestant.

Description

Given a sequence of length $n$, you need to support the following $6$ operations: - Add an integer $x$ to an interval $[l,r]$. - In an interval $[l,r]$, change all numbers less than $x$ into $x$. - In an interval $[l,r]$, change all numbers greater than $x$ into $x$. - Query the sum of an interval $[l,r]$. - Query the maximum value of an interval $[l,r]$. - Query the minimum value of an interval $[l,r]$.

Input Format

The first line contains an integer $n$, which is the length of the sequence. The second line contains $n$ integers $a_i$, which represent the initial sequence. The third line contains an integer $m$, which is the number of operations. The next $m$ lines each contain three or four integers, representing one operation described above.

Output Format

For each operation of type $4,5,6$, output one line with one integer representing the answer.

Explanation/Hint

Constraints: $1\leq n,m\leq 5\times 10^5$, $|a_i|\leq 10^8$. When performing operation $1$, $|x| \leq 1000$. When performing operation $2$, $|x| \leq 10^8$. Translated by ChatGPT 5