#CCBCHBAHAI0000105. Chỉ số nhỏ nhất và lớn nhất trong cùng một lượt
Chỉ số nhỏ nhất và lớn nhất trong cùng một lượt
Minimum and Maximum Indices in One Scan
Source: Phuoc Hung OJ
Version: Phuoc Hung OJ Extended
Problem
Given , let and . Find
$$i_{\min}=\min\{i\mid a_i=m\},\qquad i_{\max}=\min\{i\mid a_i=M\}.$$Thus ties are resolved by the smallest 0-based index. Find both extrema and both indices in one scan.
Input
The first line contains . The second line contains the integers.
Output
Print min_value min_index max_value max_index.
Subtask
Subtask 1 (20 points): .
Subtask 2 (30 points): .
Subtask 3 (50 points): .
Example
Input
6
5 -2 9 -2 9 1
Output
-2 1 9 2
Explanation
The first minimum is at index 1 and the first maximum is at index 2.