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
2017-06-29 15:18:58
easy..once u are done with GSS1
2017-06-23 11:48:14
AC in one go B|
2017-06-18 15:56:43
good problem :)

Last edit: 2017-06-18 16:33:26
2017-06-06 14:25:36
try gss1 first then just add update !!

Last edit: 2017-06-06 14:30:50
2017-05-22 21:12:14
can anyone tell me how the 3rd query given 4 instead of 3?
2017-05-04 20:47:49
hey finally after long frustation for a week solved gss1 and gss3
2017-04-30 22:15:50
silly mistake -> one week of frustration
and FYI : wrong answer#0 or wa#1 is nothing special. it is simple wrong answer. check ur code. even i was under the false impression that wa#0 might mean runtime error or 'some weird error'. Nothing like that.

Last edit: 2017-04-30 22:17:36
2017-03-27 18:07:24
cant pass gss1 in java but works in gss3 :|
2017-03-24 16:47:34
AC in a go, do GSS1 before this!!
2017-03-02 09:06:57
AC in 3rd Go!
Typos costed me WA!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.