KGSS  Maximum Sum
This will be indicated in the input by a 'U' followed by space and then two integers i and x.
U i x, 1 ≤ i ≤ N, and x, 0 ≤ x ≤ 10^8.
This operation sets the value of A[i] to x.
Query:This will be indicated in the input by a 'Q' followed by a single space and then two integers i and j.
Q x y, 1 ≤ x < y ≤ N.
You must find i and j such that x ≤ i, j ≤ y and i != j, such that the sum A[i]+A[j] is maximized. Print the sum A[i]+A[j].
Input
The first line of input consists of an integer N representing the length of the sequence. Next line consists of N space separated integers A[i]. Next line contains an integer Q, Q ≤ 10^5, representing the number of operations. Next Q lines contain the operations.
Output
Output the maximum sum mentioned above, in a separate line, for each Query.
Example
Input: 5 1 2 3 4 5 6 Q 2 4 Q 2 5 U 1 6 Q 1 5 U 1 7 Q 1 5 Output: 7 9 11 12
hide comments
saurav7192:
20200806 10:56:08
Aced finally.............................. Last edit: 20200806 12:30:50 

skj_helloworld:
20200804 12:34:34
accepted in one go 

chefpr7:
20200702 09:09:33
AC in One Go!! Nice practice problem for newbies! 

wargang:
20200701 13:25:12
very nice problem!!


sarthak_19:
20200629 06:21:49
AC in one GO!!!!!!!!


amitesh200:
20200623 23:39:33
nice one for those who are beginners in segment tree..


noobbbbbb:
20200529 20:30:11
AC in second go


dhruvgheewala:
20200525 20:53:11
Good Question For Segment Tree Beginners. Last edit: 20200525 20:53:51 

amar_shukla1:
20200518 13:30:23
easy question,But it took me 2 hours and I understood that my implementation was shit. 

abhishek_251:
20200429 10:43:31
0.06 
Added by:  Swarnaprakash 
Date:  20090110 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  Kurukshetra 09 OPC 