#K6286. Farthest Reachable Point

    ID: 31625 Type: Default 1000ms 256MiB

Farthest Reachable Point

Farthest Reachable Point

A hero must pass a sequence of obstacles in his path. Each obstacle has a certain height, and the hero can jump over an obstacle only if its height is less than or equal to his jump capability k. The hero starts from the beginning of the sequence and will continue to proceed until he reaches an obstacle that he cannot overcome.

Given multiple test cases, determine for each test case the number of obstacles the hero can overcome consecutively from the start. The result for each test case is the count of obstacles that can be passed before encountering one that exceeds his capability.

The relationship can be formulated as: if the obstacles are given by a sequence \(a_1, a_2, \dots, a_n\) and the hero's maximum jump height is \(k\), then find the largest \(m\) (with \(0 \le m \le n\)) such that \(a_i \le k\) for every \(1 \le i \le m\) and either \(m = n\) or \(a_{m+1} > k\).

inputFormat

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

  • The first line contains an integer t representing the number of test cases.
  • For each test case, the first line contains two integers n and k where n is the number of obstacles and k is the maximum height the hero can jump.
  • The next line contains n space-separated integers representing the heights of each obstacle in order.

It is guaranteed that all provided input values are valid and follow the specified format.

outputFormat

For each test case, output a single integer representing the number of consecutive obstacles the hero can overcome. Each output should be printed on a new line to stdout.

## sample
3
5 3
1 2 3 4 5
6 1
1 1 1 1 2 2
4 4
1 3 4 2
3

4 4

</p>