#K48787. Range Update and Maximum Query

    ID: 28498 Type: Default 1000ms 256MiB

Range Update and Maximum Query

Range Update and Maximum Query

You are given an array of length \( n \) initially filled with zeros. You need to process \( m \) operations on the array. There are two types of operations:

  • Type 1: 1 l r x — For every index \( i \) satisfying \( l \leq i \leq r \), add \( x \) to the \( i^{th} \) element.
  • Type 2: 2 l r — Query the maximum value among the elements from index \( l \) to \( r \) (inclusive).

For each operation of type 2, output the result in order. The operations are provided sequentially via standard input, and all outputs should be written to standard output.

Note: Indices are 1-based.

inputFormat

The first line of input contains two integers \( n \) and \( m \), where \( n \) is the length of the array and \( m \) is the number of operations.

The following \( m \) lines each describe an operation:

  • If the operation is of type 1, the line contains four integers: 1 l r x.
  • If the operation is of type 2, the line contains three integers: 2 l r.

outputFormat

For each operation of type 2, output a single line containing the maximum value in the specified range.

## sample
5 4
1 1 3 4
1 2 5 3
2 1 5
2 2 4
7

7

</p>