A - Optimal Practice Partner Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 233

問題文

高橋君は剣道部に所属しており、今日は練習試合の相手を選ぶことになりました。

剣道部には高橋君以外に N 人の部員がいて、それぞれの部員には実力値が設定されています。部員には 1 から N までの番号が付けられており、部員 i (1 \leq i \leq N) の実力値は D_i です。

高橋君の現在の実力値は L です。高橋君が練習試合で部員 i に勝てる条件は、L \geq D_i が成り立つことです。すなわち、自分の実力値が相手の実力値以上であれば勝つことができます。

コーチは高橋君に「最も成長できる練習相手」を推薦します。コーチの方針では、高橋君が勝てる相手の中でなるべく自分に近い実力を持つ部員、すなわち実力値が最も高い部員と練習することで、最大限の成長が見込めると考えています。

具体的には、L \geq D_i を満たす部員の中で、D_i が最大となる部員が推薦されます。そのような部員が複数いる場合は、部員番号が最も小さい部員が選ばれます。

コーチが推薦する部員の番号を求めてください。

ただし、高橋君が勝てる部員が 1 人も存在しない場合は、-1 を出力してください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • 1 \leq L \leq 10^9
  • 1 \leq D_i \leq 10^9 (1 \leq i \leq N)
  • 入力はすべて整数

入力

N L
D_1 D_2 \ldots D_N
  • 1 行目には、高橋君以外の部員の数を表す整数 N と、高橋君の現在の実力値を表す整数 L が、スペース区切りで与えられる。
  • 2 行目には、各部員の実力値を表す整数 D_1, D_2, \ldots, D_N が、スペース区切りで与えられる。

出力

コーチが推薦する部員の番号を 1 行で出力せよ。高橋君が勝てる部員が存在しない場合は -1 を出力せよ。


入力例 1

5 10
3 14 10 7 10

出力例 1

3

入力例 2

3 5
8 12 6

出力例 2

-1

入力例 3

10 50
45 60 50 30 50 70 48 55 49 50

出力例 3

3

入力例 4

20 1000000000
999999999 1000000000 999999998 500000000 1000000000 999999997 800000000 1000000000 999999999 600000000 700000000 900000000 1000000000 999999996 850000000 1000000000 750000000 950000000 999999999 1000000000

出力例 4

2

入力例 5

1 1
1

出力例 5

1

Score : 233 pts

Problem Statement

Takahashi is a member of the kendo club, and today he needs to choose an opponent for a practice match.

There are N members in the kendo club other than Takahashi, and each member has a skill value assigned to them. The members are numbered from 1 to N, and the skill value of member i (1 \leq i \leq N) is D_i.

Takahashi's current skill value is L. The condition for Takahashi to win a practice match against member i is that L \geq D_i holds. In other words, he can win if his skill value is greater than or equal to the opponent's skill value.

The coach will recommend the "best practice partner for growth" to Takahashi. According to the coach's policy, practicing against the member who Takahashi can beat but whose skill is as close to his own as possible — that is, the member with the highest skill value among those he can beat — is expected to yield the maximum growth.

Specifically, among the members satisfying L \geq D_i, the member with the maximum D_i is recommended. If there are multiple such members, the one with the smallest member number is chosen.

Find the number of the member recommended by the coach.

However, if there is no member that Takahashi can beat, output -1.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • 1 \leq L \leq 10^9
  • 1 \leq D_i \leq 10^9 (1 \leq i \leq N)
  • All input values are integers.

Input

N L
D_1 D_2 \ldots D_N
  • The first line contains an integer N representing the number of members other than Takahashi, and an integer L representing Takahashi's current skill value, separated by a space.
  • The second line contains integers D_1, D_2, \ldots, D_N representing the skill values of each member, separated by spaces.

Output

Output the number of the member recommended by the coach in a single line. If there is no member that Takahashi can beat, output -1.


Sample Input 1

5 10
3 14 10 7 10

Sample Output 1

3

Sample Input 2

3 5
8 12 6

Sample Output 2

-1

Sample Input 3

10 50
45 60 50 30 50 70 48 55 49 50

Sample Output 3

3

Sample Input 4

20 1000000000
999999999 1000000000 999999998 500000000 1000000000 999999997 800000000 1000000000 999999999 600000000 700000000 900000000 1000000000 999999996 850000000 1000000000 750000000 950000000 999999999 1000000000

Sample Output 4

2

Sample Input 5

1 1
1

Sample Output 5

1