#C9928. Range Update Operations
Range Update Operations
Range Update Operations
You are given an array of n integers and q operations. Each operation is defined by three integers a, b, and k and indicates that you should add the integer k to all elements of the array from index a to index b (inclusive). This problem can be efficiently solved using the prefix sum (difference array) technique.
The range update can be represented mathematically as:
[ array[i] = array[i] + \sum_{\substack{(a, b, k) \ a \le i \le b}} k ]
Your task is to apply all q operations on the array and then output the modified array.
inputFormat
The first line contains an integer n representing the number of elements in the array.
The second line contains n space-separated integers which form the array.
The third line contains an integer q representing the number of operations.
Each of the following q lines contains three space-separated integers: a, b and k, where 0 ≤ a ≤ b < n.
outputFormat
Output the modified array as a single line containing n space-separated integers after all operations have been applied.
## sample5
1 2 3 4 5
1
1 3 10
1 12 13 14 5
</p>