#P8024. [ONTAK2015] Stumilowy sad

[ONTAK2015] Stumilowy sad

Background

Subtask 0 uses the original testdata, and Subtask 1 uses hack testdata.

Problem Description

On a straight road from left to right, there are nn regions. Each region initially has a tree planted in it. The tree in region ii has height hih_i. You need to process qq operations:

  • 1 l r c: Increase the heights of all trees in regions ll to rr by cc units.
  • 2 l r h: Fix a knife in the air at height hh and cut all trees in regions ll to rr.
  • 3 l r h: Plant a new tree of height hh in each region from ll to rr.
  • 4 l r: Query the height of the tallest tree in regions ll to rr.

Note: In this problem, height is measured relative to some horizontal plane, so negative values may appear.

Input Format

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

The second line contains nn integers h1,h2,,hnh_1, h_2, \cdots, h_n.

The next qq lines each contain three or four integers: op,l,r,cop, l, r, c, op,l,r,hop, l, r, h, or op,l,rop, l, r.

Output Format

Output several lines, each containing one integer, which is the answer to the corresponding query.

2 5
3 7
4 1 2
1 1 2 1
4 1 2
3 1 1 5
4 1 2
7
8
8

Hint

For 100%100\% of the data, 1n,q5×1051 \leq n, q \leq 5 \times 10^5, 1hi1091 \leq h_i \leq 10^9, 1lrn1 \leq l \leq r \leq n, 0c5000 \leq |c| \leq 500, 1h1091 \leq h \leq 10^9.

Translated by ChatGPT 5