#C3881. Minimum Jumps to Farthest Obstacle
Minimum Jumps to Farthest Obstacle
Minimum Jumps to Farthest Obstacle
You are given a runner who starts at position \(0\) on a one-dimensional line. Along the line, there are \(n\) obstacles placed at distinct positions in increasing order. The runner is allowed to jump a distance of at most \(K\) units in each move. In one jump, the runner must land on the furthest obstacle within reach (i.e. within the interval \([current, current + K]\)). The task is to compute the minimum number of jumps required for the runner to reach or exceed the position of the furthest obstacle.
Input Format: The first line contains two space-separated integers \(K\) and \(n\), where \(K\) is the maximum jump distance and \(n\) is the number of obstacles. The second line contains \(n\) space-separated integers representing the sorted positions of the obstacles.
Output Format: Output a single integer, the minimum number of jumps required for the runner to reach or exceed the furthest obstacle.
It is guaranteed that the obstacles are placed in increasing order and that it is always possible to reach the last obstacle given the problem constraints.
inputFormat
The input is read from standard input (stdin) and has the following format:
K n obs1 obs2 ... obsn
Where \(K\) is the maximum jump distance, \(n\) is the number of obstacles, and \(obs1, obs2, \dots, obsn\) are the positions of the obstacles in strictly increasing order.
outputFormat
Output a single integer to standard output (stdout) --- the minimum number of jumps required to reach or exceed the position of the farthest obstacle.
## sample4 4
1 2 3 7
2
</p>