#t488. 整数序列的元素最大跨度值
整数序列的元素最大跨度值
Maximum Span of an Integer Sequence
Problem Description
Given a non-negative integer sequence of length , compute its maximum span (maximum span = largest value minus smallest value).
Input Format
Two lines in total. The first line is the count (). The second line contains the non-negative integers of the sequence, not exceeding , separated by single spaces.
Output Format
One line: the maximum span of the sequence.
Sample Input
6
3 0 8 7 5 9
Sample Output
9
Constraints
; each value .
Hint
- Just track the running minimum and maximum while reading the numbers, then print
max - min.