#C696. Building Jump Game

    ID: 50777 Type: Default 1000ms 256MiB

Building Jump Game

Building Jump Game

You are given n buildings, each with a specific height and a maximum number of jumps you can perform from that building. Starting from the first building (index 0), you need to determine if it is possible to reach the last building (index n-1) by making a sequence of jumps.

From a building at index \(i\), you can jump to any building at index \(j\) such that \(i < j \leq i + \text{jumps}[i]\). Formally, the condition for a valid jump is:

[ i < j \leq i + \text{jumps}[i] ]

Output YES if you can reach the last building, and NO otherwise.

inputFormat

The input is given in three lines:

  1. The first line contains an integer \(n\) representing the number of buildings.
  2. The second line contains \(n\) space-separated integers representing the heights of the buildings.
  3. The third line contains \(n\) space-separated integers representing the maximum jump length from each building.

outputFormat

Print a single line containing YES if it is possible to jump from the first building to the last building, otherwise print NO.

## sample
5
10 20 30 40 50
1 2 1 1 0
YES