Sequence and Maximum Rise Queries
InterviewTime limit1sMemory limit512 MB
Given a sequence, process point updates and report the maximum value of a_j - a_i with i at most j inside a query range.
- Level
Medium4 of 10
- Topics
- Segment tree, Divide and conquer
- Solved
- No attempts yet
Problem
Given a sequence of length , write a program that processes the following queries.
1 k x: Change to .2 l r: Print the maximum rise of the interval . The maximum rise of is defined as
Input
The first line contains the length () of the sequence.
The second line contains the elements of the sequence. The -th element is an integer ().
The third line contains the number of queries ().
Each of the next lines contains a query. A query consists of three integers, either (, ) or ().
At least one query of type 2 is given.