/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 233 点
問題文
高橋君は学校の先生であり、期末試験の結果を集計しています。
この試験では、得点が L 点以上 R 点以下の生徒のみが合格となります。得点が低すぎる生徒はもちろん、得点が高すぎる生徒も不正の疑いがあるため、合格とはなりません。
今回の試験には N 人の生徒が受験しており、 i 番目の生徒の得点は P_i 点です。
高橋君は、合格者の中で最も得点が高い生徒の出席番号を知りたいと思っています。
合格した生徒のうち、得点が最大となる生徒の出席番号を求めてください。そのような生徒が複数いる場合は、出席番号が最も小さい生徒の番号を出力してください。ただし、合格者が一人もいない場合は -1 を出力してください。
制約
- 1 \leq N \leq 2 \times 10^5
- 0 \leq L \leq R \leq 100
- 0 \leq P_i \leq 100 (1 \leq i \leq N)
- 入力はすべて整数
入力
N L R P_1 P_2 \ldots P_N
- 1 行目には、生徒の人数を表す N 、合格となる得点の下限を表す L 、上限を表す R が、スペース区切りで与えられる。
- 2 行目には、各生徒の得点を表す P_1, P_2, \ldots, P_N が、スペース区切りで与えられる。
出力
合格した生徒のうち、得点が最大となる生徒の出席番号を 1 行で出力してください。そのような生徒が存在しない場合は -1 を出力してください。
入力例 1
5 60 80 55 72 80 90 65
出力例 1
3
入力例 2
8 50 70 45 70 60 70 80 55 30 68
出力例 2
2
入力例 3
10 40 60 35 100 25 55 60 60 75 42 38 90
出力例 3
5
Score : 233 pts
Problem Statement
Takahashi is a school teacher who is tallying the results of the final exam.
In this exam, only students who scored at least L points and at most R points will pass. Students who scored too low will not pass, and students who scored too high are also suspected of cheating, so they will not pass either.
N students took this exam, and the i-th student scored P_i points.
Takahashi wants to know the student ID of the student with the highest score among those who passed.
Find the student ID of the student with the maximum score among the students who passed. If there are multiple such students, output the student ID of the one with the smallest student ID. However, if no students passed, output -1.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 0 \leq L \leq R \leq 100
- 0 \leq P_i \leq 100 (1 \leq i \leq N)
- All inputs are integers
Input
N L R P_1 P_2 \ldots P_N
- The first line contains N representing the number of students, L representing the lower bound of passing scores, and R representing the upper bound, separated by spaces.
- The second line contains P_1, P_2, \ldots, P_N representing each student's score, separated by spaces.
Output
Output the student ID of the student with the maximum score among the students who passed, on a single line. If no such student exists, output -1.
Sample Input 1
5 60 80 55 72 80 90 65
Sample Output 1
3
Sample Input 2
8 50 70 45 70 60 70 80 55 30 68
Sample Output 2
2
Sample Input 3
10 40 60 35 100 25 55 60 60 75 42 38 90
Sample Output 3
5