Codeforces Round 1004 (Div. 2)
B
Two Large Bags
Codeforces
1200
原题
← AC →
翻译中…

You have two large bags of numbers. Initially, the first bag contains $n$ numbers: $a_1, a_2, \ldots, a_n$, while the second bag is empty. You are allowed to perform the following operations:

翻译中…
  • Choose any number from the first bag and move it to the second bag.
  • Choose a number from the first bag that is also present in the second bag and increase it by one.
翻译中…

You can perform an unlimited number of operations of both types, in any order. Is it possible to make the contents of the first and second bags identical?

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains an integer $n$ ($2 \le n \le 1000$) — the length of the array $a$. It is guaranteed that $n$ is an even number.

翻译中…

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

翻译中…

It is guaranteed that the sum of $n^2$ over all test cases does not exceed $10^6$.

翻译中…

Output

翻译中…

For each test case, print "YES" if it is possible to equalize the contents of the bags. Otherwise, output "NO".

翻译中…

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

翻译中…

Note

翻译中…

Let's analyze the sixth test case: we will show the sequence of operations that leads to the equality of the bags. Initially, the first bag consists of the numbers $(3, 3, 4, 5, 3, 3)$, and the second bag is empty.

翻译中…
  1. In the first operation, move the number $3$ from the first bag to the second. State: $(3, 4, 5, 3, 3)$ and $(3)$.
  2. In the second operation, increase the number $3$ from the first bag by one. This operation is possible because the second bag contains the number $3$. State: $(4, 4, 5, 3, 3)$ and $(3)$.
  3. In the third operation, move the number $4$ from the first bag to the second. State: $(4, 5, 3, 3)$ and $(3, 4)$.
  4. In the fourth operation, increase the number $4$ from the first bag by one. State: $(5, 5, 3, 3)$ and $(3, 4)$.
  5. In the fifth operation, move the number $5$ from the first bag to the second. State: $(5, 3, 3)$ and $(3, 4, 5)$.
  6. In the sixth operation, increase the number $3$ from the first bag by one. State: $(5, 3, 4)$ and $(3, 4, 5)$.
翻译中…

As we can see, as a result of these operations, it is possible to make the contents of the bags equal, so the answer exists.

翻译中…

样例

Input #1
9
2
1 1
2
2 1
4
1 1 4 4
4
3 4 3 3
4
2 3 4 4
6
3 3 4 5 3 3
6
2 2 2 4 4 4
8
1 1 1 1 1 1 1 4
10
9 9 9 10 10 10 10 10 10 10
Output #1
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
InputCopy OutputCopy
题目信息
题号
2067B
时间限制
1 s
内存限制
256 MB
标签
暴力
动态规划
贪心
排序

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