#C8641. Taco - Jumping Hills

    ID: 52646 Type: Default 1000ms 256MiB

Taco - Jumping Hills

Taco - Jumping Hills

You are given a series of hills with specific heights and a threshold that represents the maximum allowed difference in height between two consecutive hills. Your task is to determine whether it is possible to jump from the first hill to the last hill, provided that every jump (from one hill to the next) does not exceed the threshold.

Formally, let \( h_0, h_1, \dots, h_{n-1} \) represent the heights of the hills and let \( T \) be the threshold. The condition that must hold to successfully traverse the hills is:

\( |h_i - h_{i-1}| \leq T \quad \text{for all } i = 1, 2, \dots, n-1 \)

If the condition is met for all pairs of consecutive hills, output True; otherwise, output False.

inputFormat

The input is provided via standard input (stdin) and consists of three parts:

  • The first line contains an integer n, representing the number of hills.
  • The second line contains n space-separated integers, representing the heights of the hills.
  • The third line contains an integer T, representing the maximum allowed difference between the heights of any two consecutive hills.

outputFormat

Output a single line via standard output (stdout) that is either True or False. Output True if it is possible to traverse the hills under the given constraints; otherwise, output False.

## sample
5
1 3 5 8 10
3
True