There are $$$n$$$ points on the real line at coordinates $$$x_1 \lt x_2 \lt \ldots \lt x_n$$$. A moving point starts at $$$x_1$$$ at time $$$0$$$ and always moves at a constant speed of $$$1$$$ unit of distance per unit of time. It may change its direction of movement at any time.
For every $$$i$$$, the time between any two consecutive visits to $$$x_i$$$ must not exceed $$$t_i$$$. The visit at time $$$0$$$ is considered a visit to every point, regardless of the initial position.
Determine whether there exists an infinite trajectory satisfying all these conditions.
There is only one test case in each test file.
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$).
The second line contains $$$n$$$ integers $$$x_1, x_2, \ldots, x_n$$$ ($$$1 \le x_1 \lt x_2 \lt \ldots \lt x_n \le 10^9$$$).
The third line contains $$$n$$$ integers $$$t_1, t_2, \ldots, t_n$$$ ($$$1 \le t_i \le 10^9$$$), where $$$t_i$$$ is the maximum allowed time between consecutive visits to $$$x_i$$$.
Output Yes if such an infinite trajectory exists, or No otherwise.
You can print each letter in any case (upper or lower).
31 3 58 4 8
Yes
31 3 58 4 7
No
In both examples, the checkpoints are located at coordinates $$$1$$$, $$$3$$$, and $$$5$$$.
In the first example, you can repeatedly move between coordinates $$$1$$$ and $$$5$$$. Moving from $$$1$$$ to $$$5$$$ takes $$$4$$$ seconds, and moving back from $$$5$$$ to $$$1$$$ takes another $$$4$$$ seconds. You visit the checkpoint at coordinate $$$3$$$ whenever you pass through that coordinate. Therefore, the intervals between every two consecutive visits to the checkpoints at coordinates $$$1$$$, $$$3$$$, and $$$5$$$ are $$$8$$$ seconds, $$$4$$$ seconds, and $$$8$$$ seconds, respectively. These intervals are exactly equal to their limits $$$t_1 = 8$$$, $$$t_2 = 4$$$, and $$$t_3 = 8$$$, so this trajectory satisfies all requirements and the answer is Yes.
In the second example, it can be shown that no trajectory satisfies the requirements, so the answer is No.
| Название |
|---|


