#K89352. Maximum Elevation Difference
Maximum Elevation Difference
Maximum Elevation Difference
You are given one or more trails, where each trail is represented as a sequence of integer altitudes separated by commas. For each trail, your task is to determine the maximum elevation difference. The maximum elevation difference for a trail is defined as (\max\limits_{1 \leq i \leq n}(a_i - \min\limits_{1 \leq j \leq i}a_j)), where (a_i) represents the altitude at point (i).
For example, given the trail "10,13,5,8,12", the lowest altitude encountered is 10, and the maximum increase is (13 - 10 = 3) initially; however, after a drop to 5 later, the next rises produce a maximum difference of (12 - 5 = 7). Hence, the answer is 7.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (T) representing the number of trails. Each of the following (T) lines describes a trail as a series of comma-separated integers.
outputFormat
For each trail, output the maximum elevation difference on a separate line to standard output (stdout).## sample
1
10,13,5,8,12
7
</p>