#K89132. Maximum Elevation Gain
Maximum Elevation Gain
Maximum Elevation Gain
You are given one or more test cases. In each test case, you are given a sequence of elevation points. Your task is to compute the maximum elevation gain for each test case.
The maximum elevation gain for a test case is defined as:
\( \max_{j>i} \{E_j - E_i\} \), where at the index \(i\) the elevation is minimal before a climb and \(E_j \) is a later elevation that is higher than \(E_i\). If the elevation never increases, then the maximum gain is 0.
Input Format: The first line contains an integer \(T\), the number of test cases. For each test case, the first line contains an integer \(N\) representing the number of elevation points, followed by a line containing \(N\) space separated integers representing the elevations.
Output Format: For each test case, output a single line with the maximum elevation gain.
inputFormat
The input is read from stdin and follows the format below:
- The first line contains an integer \(T\), the number of test cases.
- For each test case:
- The first line contains an integer \(N\) representing the number of elevation points.
- The second line contains \(N\) integers separated by spaces, representing the elevation points.
outputFormat
For each test case, print a single integer on a new line representing the maximum elevation gain. The output is written to stdout.
## sample1
5
1 2 3 4 5
4
</p>