Zombie and the Caves
All submissions for this problem are available.### Read problem statements in [Hindi](http://www.codechef.com/download/translated/AUG19/hindi/ZOMCAV.pdf), [Bengali](http://www.codechef.com/download/translated/AUG19/bengali/ZOMCAV.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/AUG19/mandarin/ZOMCAV.pdf), [Russian](http://www.codechef.com/download/translated/AUG19/russian/ZOMCAV.pdf), and [Vietnamese](http://www.codechef.com/download/translated/AUG19/vietnamese/ZOMCAV.pdf) 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 \le T \le 100$ - $1 \le N \le 10^5$ - $1 \le C_i, H_i \le 10^9$ for each valid $i$ ### Subtasks **Subtask #1 (30 points):** $1 \le N \le 1,000$ **Subtask #2 (70 points):** original constraints ### Example Input ``` 2 5 1 2 3 4 5 1 2 3 4 5 5 1 2 3 4 5 5 4 3 4 5 ``` ### Example Output ``` NO YES ``` ### Explanation 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$.
|Tags||aug19, difference-array, easy, sayantan_das24, vijju123|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions