#C6599. Find the First Peak Element

    ID: 50376 Type: Default 1000ms 256MiB

Find the First Peak Element

Find the First Peak Element

You are given several test cases. In each test case, you are provided with an array of integers. A peak element in the array is defined as an element that is strictly greater than its neighbors. Formally, for an array \( A[1 \dots N] \):

  • The first element is a peak if \( A[1] > A[2] \).
  • The last element is a peak if \( A[N] > A[N-1] \).
  • Any other element \( A[i] \) (where \( 1 < i < N \)) is a peak if \( A[i] > A[i-1] \) and \( A[i] > A[i+1] \).

If the array contains only one element, that element is considered as a peak. Your task is to find the first peak element in each test case (i.e. the one appearing earliest in the array), and then output its 1-indexed position along with its value. If no such peak element exists, output -1.

Note: The array indices are considered 1-indexed for the output.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

T
N₁
A₁₁ A₁₂ ... A₁N₁
N₂
A₂₁ A₂₂ ... A₂N₂
...
NT
AT₁ AT₂ ... ATNT

Here, T is the number of test cases. For each test case, N denotes the number of elements in the array, followed by N integers representing the array.

outputFormat

For each test case, output the result on a new line. If a peak element is found, print two space-separated integers: the 1-indexed position of the peak element and its value. Otherwise, print -1.

## sample
3
6
1 3 20 4 1 0
5
10 20 15 2 23
3
5 10 5
3 20

2 20 2 10

</p>