Maximum range sum? 1
InterviewTime limit1sMemory limit128 MB
Maintain an array under point updates. For each range query, find the maximum of U times a subarray sum plus V times its length over all subarrays inside the range.
- Level
Medium5 of 10
- Topics
- Array, Brute force, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
You are given a sequence of length and two constants and .
There are queries of two kinds.
- Given and , find the maximum value of over all , 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 and . If is 1, the query is of the second kind and , .
Output
For each query of the first kind, print its result on its own line.