#K32932. Predicting Species Population Growth
Predicting Species Population Growth
Predicting Species Population Growth
You are given n species, each with an initial population. In addition, you are provided with m rules, where each rule describes how the population of one species changes over time. Each rule is presented as a triple \( (i, \Delta, T) \), meaning that for the species with index \( i \), its population increases by \( \Delta \) every \( T \) days. The population change due to a rule is applied \( \lfloor \frac{days}{T} \rfloor \) times over a given number of days.
The overall formula for a species \( i \) which has one or more applicable rules is:
[ population[i] = initial[i] + \sum_{\text{rule on } i} \Delta \times \left\lfloor \frac{days}{T} \right\rfloor ]
Your task is to compute the final population for each species after a given number of days.
inputFormat
The input is given through standard input (stdin) in the following format:
n p1 p2 ... pn m i1 \( \Delta_1 \) T1 i2 \( \Delta_2 \) T2 ... (m lines in total) days
Where:
n
is the number of species.- The second line contains
n
integers representing the initial population of each species. m
is the number of rules.- Each of the next
m
lines contains three integers: the 0-indexed species id, the change amount \( \Delta \), and the interval \( T \) (in days). - The last line contains
days
, the number of days to simulate.
outputFormat
Output through standard output (stdout) the final populations of all species in a single line separated by a space.
## sample3
100 150 200
2
0 10 2
1 -5 3
10
150 135 200