P22364 [CodeChef] ZOMCAV
提高-
题目描述

Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

There are $N$ caves in a row, numbered $1$ through $N$. For each valid $i$, the radiation power in the $i$-th cave is $C_{i}$. Originally, the radiation level in each cave was $0$. Then, for each valid $i$, the radiation power in cave $i$ increased the radiation levels in the caves $i-C_{i}, \ldots, i+C_{i}$ inclusive (if they exist) by $1$, so all the caves are radioactive now.

Radiation is not the only problem, though. There are also $N$ zombies with health levels $H_{1}, H_{2}, \ldots, H_{N}$. You want to kill all of them by getting them to the caves in such a way that there is exactly one zombie in each cave. A zombie dies in a cave if and only if the radiation level in that cave is equal to the health level of the zombie. Is it possible to kill all the zombies?

------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains $N$ space-separated integers $C_{1}, C_{2}, \ldots, C_{N}$.
The third line contains $N$ space-separated integers $H_{1}, H_{2}, \ldots, H_{N}$.

------ Output ------
For each test case, print a single line containing the string "YES" if it is possible to kill all the zombies or "NO" if it is impossible (without quotes).

------ Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 10^{5}$
$1 ≤ C_{i}, H_{i} ≤ 10^{9}$ for each valid $i$

------ Subtasks ------
Subtask #1 (30 points): $1 ≤ N ≤ 1,000$

Subtask #2 (70 points): original constraints

----- Sample Input 1 ------
2

5

1 2 3 4 5

1 2 3 4 5

5

1 2 3 4 5

5 4 3 4 5
----- Sample Output 1 ------
NO

YES
----- explanation 1 ------
In both example test cases, the final radiation levels in the caves are $(5, 5, 4, 4, 3)$. For example, the radiation power in cave $1$ increased the radiation levels in caves $1$ and $2$ (there is no cave $0$) by $1$, and the radiation power in cave $4$ increased the radiation levels in all caves by $1$.

输入格式

见题面

输出格式

见题面

样例输入
2 5 1 2 3 4 5 1 2 3 4 5 5 1 2 3 4 5 5 4 3 4 5
样例输出
NO YES