#K82137. Load Distribution Optimization

    ID: 35909 Type: Default 1000ms 256MiB

Load Distribution Optimization

Load Distribution Optimization

You are given n service points and their respective capacity limits along with m areas. Each area is designated to a service point, and each area has a number of residents living in it. Your task is to calculate the total load for each service point by summing the residents of all areas assigned to that service point. Formally, for each service point i (where 1 ≤ i ≤ n), compute:

$load_i = \sum_{\{area\,|\,index=i\}} residents$

It is guaranteed that the total load at any service point does not exceed its capacity. In cases where the distribution is balanced naturally, your computation should reflect that.

inputFormat

The input is given via standard input (stdin) in the following format:

  • The first line contains an integer n (the number of service points).
  • The second line contains n space-separated integers representing the capacities of the service points.
  • The third line contains an integer m (the number of areas).
  • Each of the next m lines contains two integers: the first integer is the service point index (between 1 and n) to which the area belongs, and the second integer is the number of residents in that area.

outputFormat

The output should be printed to standard output (stdout) as a single line containing n space-separated integers. The i-th integer denotes the total number of residents assigned to the i-th service point.

## sample
3
100 150 200
6
1 50
1 40
2 70
2 60
3 100
3 110
90 130 210