#K89207. Array Query Operations
Array Query Operations
Array Query Operations
This problem involves processing queries on an integer array. The array is 1-indexed, and you will be given two types of queries:
- Update Query (Type 1): Given indices x and value y, update the x-th element of the array to y.
- Sum Query (Type 2): Given indices l and r, calculate the sum of the elements from index l to r (inclusive) and output the result.
All queries should be processed in the order given. Note that indices are 1-indexed. If the query is an update (type 1), no output is produced. For a sum query (type 2), output the computed sum on a new line.
The mathematical definition for the sum operation can be written in \( \LaTeX \) as follows:
\[ S(l,r)=\sum_{i=l}^{r}a_i \]inputFormat
Input is read from standard input (stdin) with the following format:
- The first line contains two integers \( n \) and \( q \), where \( n \) is the number of elements in the array and \( q \) is the number of queries.
- The second line contains \( n \) space-separated integers representing the initial array.
- The next \( q \) lines each describe a query in one of the following formats:
- "1 x y" — update query: change the x-th element to \( y \).
- "2 l r" — sum query: output the sum of elements from index \( l \) to \( r \) (inclusive).
outputFormat
For each sum query (type 2), output the result on a separate line to standard output (stdout). If there are no sum queries, do not output anything.
## sample5 3
1 2 3 4 5
2 1 3
1 2 7
2 2 5
6
19
</p>