#C4501. Total Elevation Gains

    ID: 48047 Type: Default 1000ms 256MiB

Total Elevation Gains

Total Elevation Gains

You are given several hikes. For each hike, you are provided with a sequence of elevation changes. The task is to compute the total elevation gain for each hike.

For a single hike, if the elevation changes are given by \(a_1, a_2, \ldots, a_n\), the total elevation gain is defined as:

[ G = \sum_{i=1}^{n} \max(0, a_i) ]

Note that negative elevation changes are ignored in the summation as they represent descents, not gains.

The input will be given via standard input (stdin), and your solution should print the results via standard output (stdout).

inputFormat

The input starts with an integer \(H\) denoting the number of hikes. For each hike, the first integer \(N\) represents the number of elevation change observations followed by \(N\) space‐separated integers which represent the elevation changes.

Example:

3
5 5 -2 3 0 4
5 4 4 -1 0 -3
5 0 -2 2 5 -1

outputFormat

Print a single line containing \(H\) space-separated integers where each integer represents the total elevation gain for the corresponding hike.

For the sample input above, the output should be:

12 8 7
## sample
3
5 5 -2 3 0 4
5 4 4 -1 0 -3
5 0 -2 2 5 -1
12 8 7