B - First Alert Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 233

問題文

高橋君はサーバーの監視システムを担当しています。このシステムでは、 N 件のログが順番に届きます。

各ログには「重要度」を表す整数値が設定されており、 i 番目( 1 \leq i \leq N )に届くログの重要度は P_i です。

高橋君は効率的な監視のため、独自のルールを設定しています。ログを 1 番目から順に確認していき、重要度が閾値 K 以上であるログを初めて見つけたら、すぐにアラートを発報して対応に向かうことにしています。一度アラートを発報したら、それ以降のログは確認しません。

高橋君がアラートを発報することになるログの番号(何番目に届いたログか)を求めてください。もし N 件すべてのログの重要度が K 未満であり、アラートを一度も発報しなかった場合は -1 を出力してください。

制約

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

入力

N K
P_1 P_2 \ldots P_N
  • 1 行目には、ログの件数を表す整数 N と、アラートを発報する重要度の閾値を表す整数 K が、スペース区切りで与えられる。
  • 2 行目には、各ログの重要度を表す整数 P_1, P_2, \ldots, P_N が、スペース区切りで与えられる。
  • P_ii 番目に届くログの重要度を表す。

出力

高橋君がアラートを発報することになるログの番号を 1 行で出力してください。ここでログの番号とは、何番目に届いたログかを表す 1 以上 N 以下の整数です。アラートを一度も発報しなかった場合は -1 を出力してください。


入力例 1

5 50
10 30 55 80 20

出力例 1

3

入力例 2

4 100
25 50 75 90

出力例 2

-1

入力例 3

10 1000000000
100 200 300 400 500 600 700 800 900 1000000000

出力例 3

10

Score : 233 pts

Problem Statement

Takahashi is in charge of a server monitoring system. In this system, N logs arrive in order.

Each log has an integer value representing its "severity level." The severity level of the i-th log (1 \leq i \leq N) to arrive is P_i.

For efficient monitoring, Takahashi has set up his own rule. He checks the logs in order starting from the 1st one, and as soon as he finds a log with a severity level of at least the threshold K, he immediately triggers an alert and goes to respond. Once an alert is triggered, he does not check any subsequent logs.

Determine the number of the log (i.e., which log in the arrival order) that causes Takahashi to trigger an alert. If the severity levels of all N logs are less than K and no alert is ever triggered, output -1.

Constraints

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

Input

N K
P_1 P_2 \ldots P_N
  • The first line contains an integer N representing the number of logs and an integer K representing the severity threshold for triggering an alert, separated by a space.
  • The second line contains integers P_1, P_2, \ldots, P_N representing the severity levels of each log, separated by spaces.
  • P_i represents the severity level of the i-th log to arrive.

Output

Print the number of the log that causes Takahashi to trigger an alert, on a single line. Here, the log number is an integer between 1 and N inclusive, representing which log it is in the arrival order. If no alert is ever triggered, print -1.


Sample Input 1

5 50
10 30 55 80 20

Sample Output 1

3

Sample Input 2

4 100
25 50 75 90

Sample Output 2

-1

Sample Input 3

10 1000000000
100 200 300 400 500 600 700 800 900 1000000000

Sample Output 3

10