No.3531 Erase Pair
タグ : / 解いたユーザー数 7
作問者 :
yt142857
Germanium32
Note
The execution time limit for this problem is $500 \mathrm{ms}$.
Problem Statement
Solve the following problem for $T$ test cases.
You are given an integer sequence $A$ of length $N$. Hijiri plays the following game using this sequence.
While $|A| \ge 2$, perform the following operation.
- Choose integers $i,j(1 \le i < j \le |A|)$, and if $A_i + A_j$ is not contained in $A$, remove $A_i$ and $A_j$ from $A$ and concatenate the remaining elements in their original order.
Yes if it is possible to keep performing the operation until $|A| \le 1$, and No otherwise. Here, $|A|$ denotes the length of the sequence $A$.
Constraints
- $1 \le T \le 2 \times 10^5$
- $2 \le N \le 2 \times 10^5$
- $|A_i| \le 10^9$
- The sum of $N$ over all test cases is at most $2 \times 10^5$
- All input values are integers
Input
$T$ $Testcase_1$ $Testcase_2$ $Testcase_3$ $\vdots$ $Testcase_T$
Each test case is given in the following format.
$N$ $A_1\ A_2\ A_3\ \cdots\ A_N$
Output
Print $T$ lines.
On the $i$-th line, print the answer for $Testcase_i$.
Sample
Sample 1
Input
3 3 3 1 4 4 2 0 2 6 4 -1 9 -5 8
Output
Yes No Yes
For the $1$st test case, for example, $A_1 + A_3 = 7$ and $7$ is not contained in $A$, so you can erase the pair $A_1$ and $A_3$ and achieve $|A| \le 1$.
Also, since $A_1 + A_2 = 4 = A_3$, you cannot erase the pair $A_1$ and $A_2$.
For the $2$nd test case, since $A_2 + A_4 = 6 = A_4$, you cannot erase the pair $A_2$ and $A_4$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。