spoj#KGSS. Maximum Sum
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
<div id="ccontent">
<!-- google_ad_section_start -->
hide comments
<!-- google_ad_section_end -->
</div>
<table width="100%">
<tbody><tr>
<td colspan="2" height="20px"></td>
</tr>
<form method="post" action="/comment/KGSS/add/"></form>
<tr> <td style="" colspan="2">Leave a Comment</td> </tr>
<tr>
<td valign="top"></td>
<td><textarea name="content" rows="3" class="form-control"></textarea></td>
</tr>
<tr>
<td colspan="2" style=""><br>
<input type="submit" value="Publish" class="btn btn-default">
<input type="hidden" name="pcode" value="KGSS">
</td>
</tr>
<tr>
<td colspan="2">
Notes:
1. Don't post any source code here.
2. Please be careful, leave short comments only. Don't spam here.
3. For more discussion (hints, ideas, solutions) please visit our forum.
4. Authors of the problems are allowed to delete the post and use html code here (e.g. to provide some useful links). </td> </tr>
</tbody></table>