#C4985. Hiking Trail Feasibility Check
Hiking Trail Feasibility Check
Hiking Trail Feasibility Check
You are given a hiking trail represented by a sequence of points, each with a specific altitude. Your task is to determine if it is possible to complete the hike from the first point to the last point such that the altitude difference between any two consecutive points does not exceed a given threshold \(D\). Formally, for every consecutive pair of points \(i-1\) and \(i\) (with \(1 \leq i < N\)), the condition \(|heights[i] - heights[i-1]| \leq D\) must hold true.
If the condition holds for all pairs (or if there is only one point), the hike is considered feasible, and you should output True. Otherwise, output False.
inputFormat
The input is provided via standard input (stdin) with the following format:
- The first line contains a single integer \(N\), the number of points on the hiking trail.
- The second line contains \(N\) space-separated integers representing the altitudes (\(heights\)) of the points.
- The third line contains a single integer \(D\), the maximum allowable altitude difference between consecutive points.
outputFormat
Output a single line via standard output (stdout) containing either True if the hike is feasible or False if it is not.
## sample5
1 2 4 7 10
3
True
</p>