#C11727. Container Extraction Operations
Container Extraction Operations
Container Extraction Operations
You are given n containers, each with a specified initial volume. Then you are given m extraction operations. In each extraction operation, c units will be removed from container a and added to container b. The containers are numbered from 1 to n.
After performing all the operations, print the final volume of each container in order, separated by spaces.
inputFormat
The input is provided via standard input (stdin) and follows the format below:
- The first line contains an integer \(n\) (\(1 \le n \le 10^5\)), representing the number of containers.
- The second line contains \(n\) space-separated integers, representing the initial volumes of the containers.
- The third line contains an integer \(m\), representing the number of extraction operations.
- Each of the next \(m\) lines contains three space-separated integers \(a_i\), \(b_i\), and \(c_i\), which describe an extraction operation: \(c_i\) units are transferred from container \(a_i\) to container \(b_i\).
outputFormat
Output the final volumes of the containers on one line, separated by a space. The output should be sent to standard output (stdout).
## sample4
10 20 30 40
3
1 2 5
2 3 10
4 1 20
25 15 40 20