To witness secrets sealed, one must endure the harshest punishment.
The Knight wants to cross the Path of Pain. The Path of Pain is a sequence of floors and spikes. The Knight can stand on floors, but he dies if he stands on spikes. The Path of pain may look something like this:
Where a $\#$ represents a floor and a $*$ represents spikes. The Knight starts on the leftmost floor and wants to end up on the rightmost floor.
The Knight has three moves:
Since the Knight cannot fly, he will start falling after completing a jump, and after dashing or walking into empty space.
Given the description of the Path of Pain, determine whether or not the Knight can cross it without dying using only the moves described above.
The first line of input contains a single integer $n$, the length of the Path of Pain ($1 \leq n \leq 10^5$).
The next $n$ lines contain the description of the Path of Pain. The $i^{th}$ line contains two integers, $t_i$ and $h_i$.
$t_i$ is the type of the $i^{th}$ block. It can be either $\#$ for floor or $*$ for spikes.
$h_i$ is the height of the $i^{th}$ block ($1 \leq h_i \leq 100$).
It is guaranteed that the first and the last blocks will be floors, not spikes.
Output "YES" (without quotes) if the Knight can cross the Path of Pain, and "NO" (without quotes) if he cannot.
In the diagram below, which is the first example, a red arrow represents a dash, a blue arrow represents a jump, and a green arrow represents walking.
Input | Output |
---|---|
7 # 3 * 2 # 1 # 1 # 2 * 2 # 3 Copy
|
YES Copy
|
5 # 3 # 1 * 4 # 1 # 2 Copy
|
NO Copy
|