GSS3 - Can you answer these queries III

You are given a sequence A of N (N <= 50000) integers between -10000 and 10000. On this sequence you have to apply M (M <= 50000) operations:
modify the i-th element in the sequence or for given x y print max{Ai + Ai+1 + .. + Aj | x<=i<=j<=y }.

Input

The first line of input contains an integer N. The following line contains N integers, representing the sequence A1..AN.
The third line contains an integer M. The next M lines contain the operations in following form:
0 x y: modify Ax into y (|y|<=10000).
1 x y: print max{Ai + Ai+1 + .. + Aj | x<=i<=j<=y }.

Output

For each query, print an integer as the problem required.

Example

Input:
4
1 2 3 4
4
1 1 3
0 3 -3
1 2 4
1 3 3

Output:
6
4
-3

Added by:Bin Jin
Date:2007-08-03
Time limit:1s
Source limit:5000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: CPP
Resource:own problem

hide comments
2024-05-31 22:07:59
also the sum of maximum subarray can't be empty, even though it is clear in statement x<=i<=j<=y, but it take me a while to get it
2024-03-25 16:28:47
"max{Ai + Ai+1 + .. + Aj | x<=i<=j<=y }" mean===> maximum subarray sum from i to j.
2024-01-09 10:04:13
@noobetofnoob the statement said that max of sum of consequent element in array
2023-08-30 00:24:49
<snip>
[Simes]: no thanks.

Last edit: 2023-08-30 07:44:02
2023-07-03 10:05:21
ok
2021-06-20 20:12:11
int also works
2021-05-30 14:25:49
HEYY
dont use llmin, llmin/2
just use -100000

Last edit: 2021-05-30 14:26:33
2021-05-13 16:38:01
To solve this giant in the first attempt feels like an accomplishment,
2020-12-08 10:32:06
One hell of a question!
2020-11-27 13:50:39
can any one explain me how the output: 6 4 -3 came
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.