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
ab_biswas09:
20190303 05:49:07
AC IN ONE GO >> Cakewalk 

trung99nb:
20190113 09:11:18
AC in one go 

sonuexpc:
20181229 13:14:34
segment tree done the job...AC in 1 go :) 

jhorar_1995:
20180824 12:28:10
by using a structure array for the max and second max is not working in java...tle


itachi_2324:
20180630 10:25:20
My 100th :) Modified Range maximum Query


vivek_dwivedi:
20180622 16:51:30
Dont know why structured array is giving tle . Segment tree work's fine worth solving the problem. Must do it


lamia2658:
20180531 11:10:55
nice problem.. learnt a lot.. AC in 1st go.. :) must try problem for beginner 

atharva_sarage:
20180406 08:51:22
AC in first attempt!!! 

hrsh_sengar:
20180312 12:14:46
my 99th :) 

badboy_1496:
20180303 20:53:30
AC in one go!!!!

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 