Codeforces Round 1002 (Div. 2)
A
Milya and Two Arrays
Codeforces
800
原题
←B →
翻译中…

An array is called good if for any element $x$ that appears in this array, it holds that $x$ appears at least twice in this array. For example, the arrays $[1, 2, 1, 1, 2]$, $[3, 3]$, and $[1, 2, 4, 1, 2, 4]$ are good, while the arrays $[1]$, $[1, 2, 1]$, and $[2, 3, 4, 4]$ are not good.

翻译中…

Milya has two good arrays $a$ and $b$ of length $n$. She can rearrange the elements in array $a$ in any way. After that, she obtains an array $c$ of length $n$, where $c_i = a_i + b_i$ ($1 \le i \le n$).

翻译中…

Determine whether Milya can rearrange the elements in array $a$ such that there are at least $3$ distinct elements in array $c$.

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases. The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($3 \le n \le 50$) — the length of the arrays $a$ and $b$.

翻译中…

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — the elements of the array $a$.

翻译中…

The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 10^9$) — the elements of the array $b$.

翻译中…

Output

翻译中…

For each test case, output $«$YES$»$ (without quotes) if it is possible to obtain at least $3$ distinct elements in array $c$, and $«$NO$»$ otherwise.

翻译中…

You can output each letter in any case (for example, $«$YES$»$, $«$Yes$»$, $«$yes$»$, $«$yEs$»$ will be recognized as a positive answer).

翻译中…

Note

翻译中…

In the first test case, you can swap the second and third elements. Then the array $a = [1, 1, 2, 2]$, $b = [1, 2, 1, 2]$, and then $c = [2, 3, 3, 4]$.

翻译中…

In the second test case, you can leave the elements unchanged. Then $c = [2, 3, 4, 4, 3, 2]$.

翻译中…

In the third test case, the array $a$ will not change from rearranging the elements in it. Then $c = [2, 2, 2]$, so the answer is $«$NO$»$.

翻译中…

样例

Input #1
5
4
1 2 1 2
1 2 1 2
6
1 2 3 3 2 1
1 1 1 1 1 1
3
1 1 1
1 1 1
6
1 52 52 3 1 3
59 4 3 59 3 4
4
100 1 100 1
2 2 2 2
Output #1
YES
YES
NO
YES
NO
InputCopy OutputCopy
题目信息
题号
2059A
时间限制
1 s
内存限制
256 MB
标签
构造
贪心
排序

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