A Segment Tree Problem
View as PDFGiven an integer array of size
, support
queries of the following types:
MAX l rFind the value of the largest element in the array from indexto index
.
UPD i xUpdate the element at indexto value
.
Input Specification
The first line contains single spaced integers
and
, representing the size of the array and the number of queries.
The second line contains single spaced integers,
, the initial elements of
.
The next lines are of one of two forms:
- String
MAXand integersand
, single spaced.
- String
UPDand integersand
, single spaced.
Output Specification
For each query of form , output the maximum value in the given range on a new line.
Constraints
Sample Input 1
5 4
6 7 4 2 0
MAX 2 4
MAX 2 3
UPD 2 1
MAX 1 2
Output for Sample Input 1
7
7
6
Comments