Submit | All submissions | Best solutions | Back to list |
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
|
||||||||||||||
2015-09-02 10:15:46
YOU SHALL NOT PASS *******EDIT******* hmmm, it passed.... Last edit: 2015-09-02 12:04:43 |
||||||||||||||
2015-08-25 12:01:59 jas.py
there is some issue with spoj,,my same code got SIGSEGV#0 when submitted with C but passed with C++14 Last edit: 2015-08-25 12:02:28 |
||||||||||||||
2015-08-05 15:10:37 shiva
Why wrong answer #0? Please help. |
||||||||||||||
2015-08-03 00:59:42 Abdullah mohammad fakhri al-attar
What is wrong answer #0 |
||||||||||||||
2015-07-18 15:58:17 abhijeet
u need to solve gss1 first before attempting this one |
||||||||||||||
2015-06-27 18:34:47 Prismatic
Segment Tree did it easily ! |
||||||||||||||
2015-06-20 05:23:49 SangKuan
if you got wrong answer #0,make the array more bigger |
||||||||||||||
2015-02-06 14:01:38 Bojan Rosko
could someone post what is test case #0, i'm getting wrong answer, can't figure out why... EDIT: nevermind, got it working... here is some help if someone got stuck where i did 8 -1 -1 -1 20 20 -1 -1 -1 1 1 3 6 Last edit: 2015-02-06 14:15:13 |
||||||||||||||
2015-01-26 11:57:01 sai krishna
Segment tree did it |
||||||||||||||
2015-01-20 20:59:13 swordfish12
@rishab agarwal, use segment trees |