#P7314. [COCI 2018/2019 #3] Pismo
[COCI 2018/2019 #3] Pismo
Description
You are given an array containing integers.
For an interval in this array (), its value is defined as $\max(A[L],A[L+1],\cdots,A[R])-\min(A[L],A[L+1],\cdots,A[R])$.
Find the minimum value among all interval values in the array.
Input Format
The first line contains a positive integer .
The second line contains integers , representing the numbers in the array.
Output Format
Output the minimum value among all interval values.
2
1 3
2
3
1 1 1
0
5
1 2 1 2 1
1
Hint
Explanation for Sample 3
A valid interval is . The value of this interval is , which is the smallest among all intervals.
Constraints
For the testdata worth points, .
For the testdata worth points, .
For of the testdata, , .
Notes
This problem’s score follows the original COCI settings, with a full score of .
Translated from COCI2018-2019 CONTEST #3 T2 Pismo.
Translated by ChatGPT 5
京公网安备 11011102002149号