#K59912. Taco Array Operations
Taco Array Operations
Taco Array Operations
You are given an array of n integers and q operations. There are two types of operations:
U x y
: Update the array element at index \(x\) to the new value \(y\).S l r
: Compute the sum of elements in the range from index \(l\) to \(r\) (inclusive) and output the result.
All indices are 1-indexed. Process the operations in the given order and for each sum query output the corresponding result on a separate line.
Note: The input is read from standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The first line contains two integers \(n\) and \(q\) separated by a space, where \(n\) is the number of elements in the array and \(q\) is the number of operations.
The second line contains \(n\) space-separated integers representing the array.
The following \(q\) lines each contain an operation in one of the two formats:
U x y
: Update the \(x\)-th element to \(y\).S l r
: Output the sum of elements from index \(l\) to \(r\) (inclusive).
outputFormat
For each sum query operation (i.e., operations starting with S
), output the resulting sum on a new line, in the same order as the queries appear in the input.
5 3
1 2 3 4 5
U 3 10
S 2 4
S 1 5
16
22
</p>