#K38042. Range Increment Operations
Range Increment Operations
Range Increment Operations
You are given an array of n integers. Your task is to perform q range increment operations. Each operation is defined by three integers b, e, and k, meaning that you should add k to each array element in the range \( [b, e) \) (using 0-indexing).
After executing all operations, output the updated array with each element separated by a space.
Note: The interval \( [b, e) \) includes index \( b \) and excludes index \( e \).
Example: For the array [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and the following operations:
1 5 3 3 7 -2
The updated array will be: [1, 5, 6, 5, 6, 4, 5, 8, 9, 10].
inputFormat
The input is read from standard input and consists of the following:
- The first line contains an integer n, the number of elements in the array.
- The second line contains n integers separated by spaces, representing the elements of the array.
- The third line contains an integer q, the number of operations.
- Each of the next q lines contains three integers b, e, and k separated by spaces. Each line represents an operation to add k to all elements in the range \( [b, e) \).
Note: The indices are 0-indexed.
outputFormat
Output the updated array as a single line of space-separated integers after performing all the operations.
## sample10
1 2 3 4 5 6 7 8 9 10
2
1 5 3
3 7 -2
1 5 6 5 6 4 5 8 9 10