#K64652. Garden Operations
Garden Operations
Garden Operations
You are given a garden with n plots, numbered from 1 to n, and each plot has an initial height. You will be asked to perform m operations on this garden. There are two types of operations:
- Type 1 (Update):
1 l r h
. Increase the height of every plot from index l to r by h. Mathematically, for each i such that
\( l \le i \le r \), update \( h_i \) as follows:
\( h_i = h_i + h \).</p> - Type 2 (Query):
2 l r
. Query the maximum height among plots from index l to r. That is, output \( \max\{h_l, h_{l+1}, \ldots, h_r\} \).
It is guaranteed that the input operations will be valid. For operations of type 2, output the result on a new line. Note that if there are no query operations, nothing should be printed.
inputFormat
The first line contains two space-separated integers n and m — the number of plots and the number of operations respectively.
The second line contains n space-separated integers representing the initial heights of the plots.
Each of the following m lines contains an operation in one of the following forms:
1 l r h
— increase the heights of plots from l to r by h.2 l r
— query and output the maximum height among plots from l to r.
outputFormat
For each query operation (type 2), output the maximum height in the specified interval on a new line. If there are no query operations, output nothing.
## sample6 5
1 2 3 4 5 6
2 1 6
1 2 4 2
2 2 5
1 1 3 1
2 1 3
6
6
6
</p>