#K73462. Array Operations
Array Operations
Array Operations
You are given an array of integers of size (n) and (q) queries. Each query is of one of the following two types:
1. Update Query: Formatted as (u\ i\ x), which updates the element at index (i) to the value (x).
2. Sum Query: Formatted as (s\ l\ r), which asks you to compute the sum of elements in the interval ([l, r]) (inclusive).
Your task is to process these queries sequentially and output the result for each sum query on a new line. This problem tests your ability to efficiently process and update arrays based on dynamic queries.
inputFormat
The input is given via standard input (stdin) in 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 content of the array.
Each of the next (q) lines contains a query in one of the two formats:
- (u\ i\ x): Update the element at index (i) to (x).
- (s\ l\ r): Compute and output the sum of array elements from index (l) to (r) (inclusive).
outputFormat
For each sum query, print the computed sum on a new line to the standard output (stdout).## sample
5 4
1 2 3 4 5
u 1 10
s 0 2
u 3 8
s 2 4
14
16
</p>