CF1717C Madoka and Formal Statement

题目描述

给定一个数列 $a_{1…n}$, 如果满足下面条件, 你可以使 $a_i = a_i + 1$: - $i < n$ 且 $a_i \leq a_{i+1}$ - $i = n$ 且 $a_i \leq a_{1}$ 再给定一个数列 $b_{1…n}$, 问 $a$ 是否可以通过上述操作变为 $b$.

输入格式

本题多测. 第一行为 $t$, 表示 $t$ 组数据. 接下来 $t$ 组数据,每组第一行为一个正整数 $n$, 第二行为 $n$ 个整数, 代表数列 $a$; 第三行为 $n$ 个整数, 代表数列 $b$. 保证 $\Sigma n \le 2×10^5$.

输出格式

对于每组数据,输出 `"YES"` 或 `"NO"`.

说明/提示

In the first test case, the array $ a $ is already equal to the array $ b $ . In the second test case, we can't get the array $ b $ , because to do this we need to decrease $ a_1 $ . In the fifth test case, we can apply operations in order to the elements with indices $ 4, 3, 3,2,2,2,1,1,1,1 $ , and then get the array $ [5,5,5,5,5] $ . After that, you can apply operations in order to elements with indices $ 5,4,4,3,1 $ and already get an array $ [6,5,6,7,6] $ .