#C2604. Maximum Altitude Difference
Maximum Altitude Difference
Maximum Altitude Difference
You are given several test cases. For each test case, you are provided with an integer N representing the number of waypoints and a list of N integers representing the altitudes at those waypoints. Your task is to compute the maximum altitude difference for each test case.
Formally, for a given sequence of altitudes \(a_1, a_2, \ldots, a_N\), the maximum altitude difference is defined by the formula:
[ \text{Maximum Difference} = \max_{1 \leq i \leq N}(a_i) - \min_{1 \leq i \leq N}(a_i) ]
Print the result for each test case on a new line.
inputFormat
The input is read from standard input and has the following format:
T N a1 a2 ... aN N a1 a2 ... aN ... (repeated for T test cases)
Where:
T
is the number of test cases.- For each test case, an integer
N
indicates the number of waypoints, followed by a line withN
space-separated integers representing the altitudes.
outputFormat
For each test case, output a single integer representing the maximum altitude difference. Each result should be printed on a separate line.
## sample1
5
100 200 150 500 300
400
</p>