#K51707. Tree Planting Campaign

    ID: 29147 Type: Default 1000ms 256MiB

Tree Planting Campaign

Tree Planting Campaign

In this problem, you are required to simulate a tree planting campaign over a number of weeks. There are (N) sections, and initially each section has (M) trees. For (W) weeks, each section will have trees planted and trees cut down. In the (i)-th week, every section gets (P_i) new trees and loses (D_i) trees. The update rule is given by: [ \text{trees}{week_i} = \text{trees}{week_{i-1}} + (P_i - D_i) \quad (1 \leq i \leq W) ] After each week, print the number of trees in every section (all sections have the same count).

Example:
If the input is 3 5 2 on the first line (i.e. 3 sections, 5 initial trees, 2 weeks), followed by 3 4 (trees planted each week) and 2 1 (trees cut each week), then the weekly outcomes will be:

  • Week 1: \(5+3-2 = 6\) trees per section.
  • Week 2: \(6+4-1 = 9\) trees per section.
The output will be two lines: 6 6 6 9 9 9

inputFormat

The input is given via standard input (stdin) and consists of three lines:

  • The first line contains three integers: \(N\) (number of sections), \(M\) (initial number of trees in each section), and \(W\) (number of weeks).
  • The second line contains \(W\) integers, representing the number of trees planted in each section for each week: \(P_1, P_2, \ldots, P_W\).
  • The third line contains \(W\) integers, representing the number of trees cut down from each section for each week: \(D_1, D_2, \ldots, D_W\).

outputFormat

The output should be printed to standard output (stdout). For each week, print a single line containing (N) space-separated integers representing the number of trees in each section at the end of that week.## sample

3 5 2
3 4
2 1
6 6 6

9 9 9

</p>