問題一覧 > 通常問題

No.3531 Erase Pair

レベル : / 実行時間制限 : 1ケース 0.500秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 7
作問者 : yu23578 / テスター : aa36 Yoyoyo8128 yt142857 Germanium32 GaLLium
お気に入りにしたユーザー ProblemId : 13080 / 自分の提出
問題文最終更新日: 2026-05-04 21:28:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
聖光学院プログラミングコンテスト2026 day2 (順位表) の他の問題:

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.

Print 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もしくは右上の雲マークをクリックしてアカウントを作成してください。