Problems > Point Assign, Range Max

Point Assign, Range Max

Difficulty: 1700 5000 ms 128 MB

segment-tree

Support U i v (assign ai = v) and Q l r (print the maximum of al..r).

Input: the first line has N and Q; the second line has the array; each of the next Q lines is an operation.

Output: one line per query.

Constraints:

  • 1 ≤ N, Q ≤ 105
  • |values| ≤ 106

Sample Tests

Input 1
5 3
1 5 2 4 3
Q 1 5
U 2 0
Q 1 3
Output 1
5
2
Input 2
1 1
7
Q 1 1
Output 2
7

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.