#K47477. Array Operations

    ID: 28207 Type: Default 1000ms 256MiB

Array Operations

Array Operations

You are given an array of \( n \) integers and \( q \) operations. Each operation is either an update or a sum query. The update operation is represented as U x v, which means update the element at the \( x \)-th position (1-indexed) to the new value \( v \). The sum query is represented as S l r, which requests the sum of the subarray from index \( l \) to \( r \) (inclusive).

For each sum query, output the result on a new line.

inputFormat

The first line contains two space-separated integers \( n \) and \( q \), the number of elements in the array and the number of operations, respectively.

The second line contains \( n \) space-separated integers representing the initial array.

The following \( q \) lines each contain an operation in one of the following formats:

  • U x v: Update the \( x \)-th element (1-indexed) to \( v \).
  • S l r: Query the sum of the subarray from index \( l \) to \( r \) (inclusive).

outputFormat

For each query of type S l r, output a single integer representing the sum of the corresponding subarray on a new line.

## sample
5 5
1 2 3 4 5
S 1 3
U 2 10
S 1 3
S 2 4
U 5 0
6

14 17

</p>