#K58857. Supported Weight Calculation
Supported Weight Calculation
Supported Weight Calculation
You are given several columns, each containing a stack of products with specified weights. The weights are provided from the bottom product to the top product. For each product, determine the total weight it supports, which is the sum of its own weight and the weights of all products above it.
In other words, for a column with weights \(w_1, w_2, \dots, w_h\) (from bottom to top), the supported weight for the \(i^{th}\) product is defined as \(S_i = \sum_{j=i}^{h} w_j\). Your task is to compute these supported weights for each column and output them with each column's result on a new line.
For example, if one column has weights [10, 20, 30] (from bottom to top), then the supported weights are [60, 50, 30] because:
\[ S_1 = 10 + 20 + 30 = 60, \quad S_2 = 20 + 30 = 50, \quad S_3 = 30 \]inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a single integer \(c\), the number of columns.
- The following \(c\) lines each describe a column. Each line starts with an integer \(h\) (the number of products in that column), followed by \(h\) space-separated positive integers representing the weights of the products from bottom to top.
outputFormat
For each column, print a single line to standard output (stdout) containing \(h\) space-separated integers. These integers represent the supported weights for the products in that column, starting from the bottom product.
## sample1
3 10 20 30
60 50 30
</p>