#K45172. Reach the End

    ID: 27695 Type: Default 1000ms 256MiB

Reach the End

Reach the End

You are given a list of N platforms with corresponding heights a1, a2, ..., aN and an integer threshold T. Starting from the first platform, your task is to determine if it is possible to reach the last platform by performing a series of jumps.

A jump from the current platform ai to a subsequent platform aj is allowed if and only if:

\( a_j \leq a_i + T \)

You must choose the furthest reachable platform in each step. If at some point no progress can be made, then it is impossible to reach the end.

Determine whether you can reach the last platform. Output "YES" if it is possible, or "NO" if it is not.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains a single integer N representing the number of platforms.
  • The second line contains N space-separated integers representing the heights of the platforms.
  • The third line contains a single integer T, which is the maximum height increase allowed for a jump.

Here, T can be considered as a threshold such that a jump from a platform with height ai to another platform aj is valid if \( a_j \leq a_i + T \).

outputFormat

Output a single string to standard output (stdout): "YES" if it is possible to reach the last platform; otherwise, output "NO".

## sample
5
3 4 5 6 8
2
YES