#C6366. Lowering Hurdle Problem

    ID: 50118 Type: Default 1000ms 256MiB

Lowering Hurdle Problem

Lowering Hurdle Problem

A dog is training to jump over a series of hurdles. The dog has a fixed jump capacity \(k\). It attempts to jump each of the \(n\) hurdles in order. When the dog encounters a hurdle with height \(H_i\) that exceeds its jump capacity (i.e. \(H_i > k\)), it fails to clear that hurdle. Your task is to determine the index (1-indexed) of the first hurdle that the dog cannot jump. If all hurdles can be jumped (i.e. every \(H_i \le k\)), output -1.

Input Specification: The first line contains two integers \(n\) and \(k\), representing the number of hurdles and the dog's jump capacity respectively. The second line contains \(n\) space-separated integers, where the \(i\)-th integer represents the height \(H_i\) of the \(i\)-th hurdle.

Output Specification: Output a single integer representing the 1-indexed position of the first hurdle that exceeds the dog's jump capacity. If no hurdle exceeds \(k\), output -1.

Mathematically, find the smallest index \(i\) such that:

[ H_i > k ]

If no such \(i\) exists, output -1.

inputFormat

The input is read from standard input (stdin) and has the following format:

  1. The first line contains two integers \(n\) and \(k\) separated by a space.
  2. The second line contains \(n\) space-separated integers representing the heights \(H_1, H_2, \dots, H_n\) of the hurdles.

outputFormat

Output a single integer on standard output (stdout): the 1-indexed position of the first hurdle that is higher than \(k\). If all hurdles are within the jump capacity of the dog, output -1.

## sample
5 7
3 10 5 6 2
2

</p>