C - Second Best
解説
/


実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 200 点
問題文
長さ N の整数列 A=(A_1,\ldots,A_N) が与えられます。ここで A_1,A_2,\ldots,A_N は相異なります。
A の中で二番目に大きい要素は A の何番目の要素でしょうか。
制約
- 2\leq N\leq 100
- 1\leq A_i \leq 10^9
- A_1,A_2,\ldots,A_N は相異なる
- 入力される数値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 A_2 \ldots A_{N}
出力
A の中で二番目に大きい要素が A の X 番目であるとき、X を整数として出力せよ。
入力例 1
4 8 2 5 1
出力例 1
3
A の中で二番目に大きい要素は A_3 なので 3 を出力してください。
入力例 2
8 1 2 3 4 5 10 9 11
出力例 2
6
Score : 200 points
Problem Statement
You are given an integer sequence A=(A_1,\ldots,A_N) of length N. Here, A_1, A_2, \ldots, A_N are all distinct.
Which element in A is the second largest?
Constraints
- 2 \leq N \leq 100
- 1 \leq A_i \leq 10^9
- A_1, A_2, \ldots, A_N are all distinct.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N A_1 A_2 \ldots A_{N}
Output
Print the integer X such that the X-th element in A is the second largest.
Sample Input 1
4 8 2 5 1
Sample Output 1
3
The second largest element in A is A_3, so print 3.
Sample Input 2
8 1 2 3 4 5 10 9 11
Sample Output 2
6