#P1887C. Minimum Array
Minimum Array
No submission language available for this problem.
Description
Given an array of length consisting of integers. Then the following operation is sequentially applied to it times:
- Choose indices and () and an integer ;
- Add to all elements of the array in the segment . More formally, assign for all .
Let be the array obtained after applying the first operations (). Note that is the array before applying any operations.
You need to find the lexicographically minimum array among all arrays .
An array is lexicographically smaller than array if there is an index such that , and for all . In other words, for the first index where the arrays differ, .
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer () — the length of array .
The second line of each test case contains integers () — the elements of array .
The third line of each test case contains a single integer () — the number of operations on the array.
In each of the next lines, there are three integers , , and — the description of each operation. The operations are given in the order they are applied.
It is guaranteed that the sum of over all test cases and the sum of over all test cases do not exceed .
For each test case, output the lexicographically minimum array among all arrays .
Input
Each test consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer () — the length of array .
The second line of each test case contains integers () — the elements of array .
The third line of each test case contains a single integer () — the number of operations on the array.
In each of the next lines, there are three integers , , and — the description of each operation. The operations are given in the order they are applied.
It is guaranteed that the sum of over all test cases and the sum of over all test cases do not exceed .
Output
For each test case, output the lexicographically minimum array among all arrays .
Note
In the first test case:
- ;
- ;
- .
Thus, the lexicographically minimum array is .
In the second test case, the lexicographically minimum array is .