Maximum Interval Sum 2
Time limit1sMemory limit256 MB
For a sequence with point updates, answer range queries for the maximum of U times a subarray sum plus V times its length minus one.
- Level
Hard8 of 10
- Topics
- Segment tree, Divide and conquer, Dynamic programming, Math
- Solved
- No attempts yet
Problem
You are given an integer sequence of length and two constants and .
There are queries of two kinds.
- Given and , find the maximum of over all pairs with .
- Given and , set the value of to .
Input
The first line contains the integers , , , and . (, )
The second line contains the integers . ()
Each of the next lines contains one query as three integers , , and . ()
If is 0 the query is of the first kind, otherwise it is of the second kind. For a query of the first kind, . For a query of the second kind, and .
Output
For each query of the first kind, print its result on its own line, in the order the queries are given.