#C11273. Find Minimum Difference Pair
Find Minimum Difference Pair
Find Minimum Difference Pair
Given an array of n integers, find two indices \(i\) and \(j\) (with \(1 \le i < j \le n\)) such that \(a[i-1] \le a[j-1]\). Among all pairs satisfying the condition, choose the pair with the smallest difference \((j - i)\). If there are multiple answers with the same difference, choose the one with the smallest \(i\). If no such pair exists, output -1.
inputFormat
The first line of input contains an integer (n) (the size of the array). The second line contains (n) space-separated integers representing the array elements.
outputFormat
If a valid pair exists, output two space-separated integers representing their 1-based indices (i) and (j). Otherwise, output -1.## sample
5
1 3 2 4 5
1 2
</p>