#C11264. Minimum Upgrade Cost
Minimum Upgrade Cost
Minimum Upgrade Cost
You are given \( t \) building types. For each building type, you are provided with an integer \( k \) which represents the total number of levels for that building and \( k-1 \) integers that represent the cost required to upgrade the building from one level to the next. Your task is to compute the total coins needed to upgrade each building from its initial level to the maximum level \( k \).
Input Format: The input is read from stdin
and consists of multiple lines. The first line contains the integer \( t \). Each of the following \( t \) lines describes a building type. For each building, the first number is \( k \) (the number of levels) followed by \( k-1 \) integers that denote the upgrade costs.
Output Format: For each building type, output a single line with the total coins required for upgrading that building.
Note: All costs are positive integers.
inputFormat
The first line contains an integer \( t \) indicating the number of building types. Each of the next \( t \) lines contains a sequence of space-separated integers. The first integer of each line is \( k \) (the number of levels for the building) and the next \( k-1 \) integers represent the cost to upgrade from one level to the next.
Example:
2 3 10 20 4 5 10 15
outputFormat
Output \( t \) lines where each line contains a single integer representing the total cost to upgrade the corresponding building type from level 1 to level \( k \).
Example:
30 30## sample
2
3 10 20
4 5 10 15
30
30
</p>