#t1144. 最大值的位置
最大值的位置
Position of the Maximum
Problem Description
Third lesson on arrays: find the extremum by "fighting on the arena".
Assume the first number is the champion, then let every other number step up and challenge it: if it beats the champion, it takes the crown. Keep track of the champion's position (its index) while you go. This "arena" trick is the foundation of a whole family of problems: second largest value, index of the extremum, counting how often the extremum occurs, and so on.
Input Format
The first line contains a positive integer ; the second line contains pairwise distinct integers separated by spaces.
Output Format
One line with two integers separated by a space: the maximum value and its position (1-based).
Sample Input
5
3 7 1 9 2
Sample Output
9 4
Constraints
For 100% of the test data, , all numbers are distinct, and their absolute values do not exceed .
Hint: the position is "which number in the sequence it is" (1-based), not the array index. If you store array indices, remember to add 1 when printing.