Technocup 2022 - Elimination Round 2
C
Two Arrays
Codeforces
900
原题
← BD →
翻译中…

You are given two arrays of integers $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_n$.

翻译中…

Let's define a transformation of the array $a$:

翻译中…
  1. Choose any non-negative integer $k$ such that $0 \le k \le n$.
  2. Choose $k$ distinct array indices $1 \le i_1 \lt i_2 \lt \ldots \lt i_k \le n$.
  3. Add $1$ to each of $a_{i_1}, a_{i_2}, \ldots, a_{i_k}$, all other elements of array $a$ remain unchanged.
  4. Permute the elements of array $a$ in any order.
翻译中…

Is it possible to perform some transformation of the array $a$ exactly once, so that the resulting array is equal to $b$?

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. Descriptions of test cases follow.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n \le 100$) — the size of arrays $a$ and $b$.

翻译中…

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-100 \le a_i \le 100$).

翻译中…

The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($-100 \le b_i \le 100$).

翻译中…

Output

翻译中…

For each test case, print "YES" (without quotes) if it is possible to perform a transformation of the array $a$, so that the resulting array is equal to $b$. Print "NO" (without quotes) otherwise.

翻译中…

You can print each letter in any case (upper or lower).

翻译中…

Note

翻译中…

In the first test case, we can make the following transformation:

翻译中…
  • Choose $k = 2$.
  • Choose $i_1 = 1$, $i_2 = 2$.
  • Add $1$ to $a_1$ and $a_2$. The resulting array is $[0, 2, 0]$.
  • Swap the elements on the second and third positions.
翻译中…

In the second test case there is no suitable transformation.

翻译中…

In the third test case we choose $k = 0$ and do not change the order of elements.

翻译中…

样例

Input #1
3
3
-1 1 0
0 0 2
1
0
2
5
1 2 3 4 5
1 2 3 4 5
Output #1
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
1584C
时间限制
1 s
内存限制
256 MB
标签
贪心
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。