#C3536. Array Update and Sum
Array Update and Sum
Array Update and Sum
You are given an array \(A\) of \(n\) integers and \(q\) operations. Each operation is represented by two integers \(i\) and \(v\) which means that you should update the array element at index \(i\) (1-indexed) as follows:
$$A[i] = A[i] + v$$
After performing all \(q\) operations, output the sum of all elements in the updated array.
Note: The array uses 1-indexing in the operations.
inputFormat
The input is given via standard input and has the following format:
- 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 \(A\).
- Each of the next \(q\) lines contains two space-separated integers \(i\) and \(v\), indicating that you should add \(v\) to \(A[i]\) (using 1-indexing).
outputFormat
Output a single integer which is the sum of the updated array after performing all the operations.
## sample5 3
1 2 3 4 5
2 3
2 -2
5 10
26