問題一覧 > 通常問題

No.2343 (l+r)/2

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 77
作問者 : ytqm3 / テスター : ぷら MtSaka
お気に入りにしたユーザー ProblemId : 9669 / 自分の提出
問題文最終更新日: 2023-06-07 21:43:32
(l+r)/2
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
yukicoder contest 392 (順位表) の他の問題:

Problem Statement

Solve the following problem for $T$ test cases.

You are given a sequence $A$ of length $N$ consisting of $0,1$. You may perform the following operation on this sequence $N-1$ times.

  • Remove $2$ adjacent elements and replace them with their average.

Determine whether it is possible to make $A=(0.5)$.

Input

$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$

Each case is given in the following format.

$N$
$A_1$ $A_2$ $\ldots$ $A_N$
  • $1 \le T \le 2 \times 10^5$
  • $1 \le N \le 2 \times 10^5$
  • $A_i \in \{0,1\}$
  • The sum of $N$ over all cases does not exceed $2\times 10^5$.
  • All input values are integers.

Output

Print $T$ lines. On the $i$-th line, print the answer for $\text{case}_i$. For each case, print Yes if it is possible, and No if it is impossible.

Sample

Sample 1
Input
3
6
1 0 1 0 0 1
5
0 1 0 1 0
9
1 1 0 1 0 0 0 1 0
Output
Yes
No
Yes

For the $1$st case: you can perform the operations as $(1,0,1,0,0,1) \to (1,0.5,0,0,1) \to (1,0.5,0,0.5) \to (1,0.5,0.25) \to (0.75,0.25) \to (0.5)$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。