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-01-05 21:13:44 rishabh aggarwal
tle... any solution????? |
||||||||||||||
2014-12-19 07:14:04 j1k7_7(JaskamalKainth)
Just one change from GSS1. :) |
||||||||||||||
2014-12-03 13:35:35 Rahul
Great problem for learning segment trees. :) |
||||||||||||||
2014-11-12 15:44:33 mayank
This test case might help. 10 -1 4 5 6 -3 -4 -5 -6 -7 -8 1 1 1 10 |
||||||||||||||
2014-09-03 18:06:56 Mostafa 36a2
@EB :I think there should be a statement says: "1<=x<=N" and y in the second query is "1<=y<=N" . |
||||||||||||||
2014-08-29 19:36:43 Mostafa 36a2
@The Bear : You have to find any sub-range that is the maximum "print max{Ai + Ai+1 + .. + Aj | x<=i<=j<=y }" so if i=4,j=4 A[4]=4 is the maximum Last edit: 2014-09-03 17:59:49 |
||||||||||||||
2014-08-07 21:00:50 Ahmedali Durga
What is Wrong answer#0? |
||||||||||||||
2014-07-30 09:27:02 vikrant
@Bin Jin what does #0 mean? |
||||||||||||||
2014-07-20 15:24:20 Anirudh Rayabharam
This is complete nonsense. Why is the source limit so low? The standard is 50000 Bytes. |
||||||||||||||
2014-05-22 05:40:50 Mike OBeirne
For Java, I had to use a faster scanner (using BufferedInputReader), as well as using StringBuilder for the output. Was able to finally get it to pass, though! |