We have the altitude data recorded by a watch during a walk. The clock registers, at each unit of time, the height in meters above sea level. Write a program such that, given the sequence of altitudes, calculates the following three values:
For example, given the sequence of heights 1 2 2 4 3 5 4, the cumulative positive slope is 5, the cumulative negative slope is 2, and the highest cumulative slope in an uphill section is 3.
Exam score: 4 Automatic part: 40%
Input
On entry there is a non-negative integer n followed by a series of n cases. Each case consists of a sequence of heights. Each height is a nonnegative integer. Right after the sequence appears the -1 mark.
Output
For each case, a line with the cumulative positive slope, the cumulative negative slope, and the highest cumulative slope in an uphill section.
Input
6 1 2 2 4 3 5 4 -1 100 99 98 99 100 100 100 101 95 94 95 -1 430 435 440 425 437 450 -1 100 -1 10 20 30 10 20 20 30 33 25 10 -1 15 15 14 13 12 10 -1
Output
5 2 3 4 9 3 35 15 25 0 0 0 43 43 23 0 5 0