#C4399. Find the First Swapped Positions
Find the First Swapped Positions
Find the First Swapped Positions
You are given an array of integers. Your task is to find the first pair of consecutive elements where the left element is greater than the right element. In other words, if the array is sorted in ascending order, then no such pair exists.
If such a pair is found, output the 1-based positions of the two swapped elements as \( (i, i+1) \). Otherwise, output \( (-1, -1) \).
Note: The positions are counted starting from 1, not 0.
inputFormat
The input consists of two lines. The first line contains a single integer \( n \) indicating the number of elements in the array. The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Output a single line with two space-separated integers representing the 1-based positions of the first pair of swapped elements. If there is no such pair, output "-1 -1".
## sample5
3 2 6 4 8
1 2