#K76022. Digital Plants Growth Simulation

    ID: 34550 Type: Default 1000ms 256MiB

Digital Plants Growth Simulation

Digital Plants Growth Simulation

In this problem, you are given n plants, each having an initial height \(h_i\), a daily water requirement \(w_i\), and a growth factor \(g_i\). Each day you have a total of \(w\) units of water available. The plants are watered in the order they are given. For each plant, if the remaining water for the day is at least its water requirement, it gets watered and its height increases by its growth factor. This process is repeated for \(T\) days.

Formally, for each day and for each plant \(i\) (from 1 to \(n\)):

[ \text{if } R \geq w_i \text{ then } h_i = h_i + g_i \text{ and } R = R - w_i, ]

where \(R\) is the remaining water for that day (initially \(R = w\)).

Your task is to compute the final heights of all the plants after \(T\) days.

inputFormat

The first line contains three integers: \(n\), \(w\), and \(T\), where \(n\) is the number of plants, \(w\) is the total water available each day, and \(T\) is the number of days.

Then follow \(n\) lines, each containing three integers \(h_i\), \(w_i\), and \(g_i\) representing the initial height, the daily water requirement, and the growth factor of the \(i\)-th plant respectively.

outputFormat

Output a single line containing \(n\) integers separated by a space. These integers represent the final heights of the plants after \(T\) days.

## sample
4 10 5
2 3 1
4 2 2
6 1 3
1 4 1
7 14 21 6