Segment Tree Practice 1
View as PDFGiven an array  of size 
, support the 
 of the following operations:
- Find the sum of all elements from index 
to index
.
 - Update the element at index 
to value
.
 
Constraints
Input Specification
The first line contains  integers 
 and 
.
The second line contains  integers 
, the initial elements of 
.
The next  lines are one of two forms:
S l rrepresenting the first operation.U i xrepresenting the second operation.
Output Specification
For each type  operation output one integer on its own line, the answer to that query.
Sample Input
5 5
1 2 3 4 5
S 2 4
S 1 5
U 2 6
S 2 2
S 2 4
Sample Output
9
15
6
13
Comments