#C8371. Final Fuel Price Calculation
Final Fuel Price Calculation
Final Fuel Price Calculation
You are given N gas stations numbered from 1 to N, each with an initial fuel price. There are M update operations. In each operation, you are given three integers L, R and V which means that you should add the value V to the fuel prices of all stations in the range [L,R] (both inclusive). After performing all the update operations, you are given Q queries where each query asks for the final fuel price at a given station index.
Note: The update operations and queries use 1-indexing.
Mathematically, the final price for a station i can be determined as follows:
[ price_{final}(i) = price_{initial}(i) + \sum_{\substack{(L,R,V)\ L\leq i \leq R}} V ]
Your task is to implement a program that reads the input from stdin
and writes the result to stdout
.
inputFormat
The first line contains three integers N, M, and Q, representing the number of gas stations, the number of update operations, and the number of queries, respectively.
The second line contains N integers where the i-th integer denotes the initial fuel price of the i-th gas station.
The next M lines each contain three integers L, R, and V where L and R denote the range of station indices to be updated and V is the value to be added.
The last line contains Q integers, each representing a station index to query after all updates have been applied.
outputFormat
For each query, output the final fuel price of the respective gas station on a new line.
## sample5 3 3
2 4 8 6 10
1 3 5
2 4 10
1 1 2
3 1 5
23
9
10
</p>