問題一覧 > 通常問題

No.1990 Candy Boxes

レベル : / AI推定難易度 : 2150 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 23
作問者 : milkcoffee / テスター : tokusakurai riano
お気に入りにしたユーザー ProblemId : 7822 / 自分の提出
問題文最終更新日: 2022-05-03 20:42:56
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. Back to the original
yukicoder contest 349 (順位表) の他の問題:

Problem Statement

There are a sequence $A$ and a sequence $B$, each of length $N$. Initially, all elements of $A$ are $0$.
Consider the following operation on the sequence $A$.

  • Choose an $i$ ($1 \leq i \leq N-1$) such that $A_i$ and $A_{i+1}$ have the same parity, and add $1$ to $A_i$ and $A_{i+1}$.

  • Determine whether the sequence $A$ can be made equal to the sequence $B$ by repeating the operation $0$ or more times.

    Input

    $N$
    $B_1 \ \ B_2 \ \  \cdots \ \ B_N$
    

  • $2 \leq N \leq 2 \times 10^5$
  • $0 \leq B_i \leq 10^9$ $(1 \leq i \leq N)$
  • All input values are integers.
  • Output

    If it is possible to make the sequence $A$ equal to the sequence $B$ through operations, print Yes; otherwise, print No.

    Sample

    Sample 1
    Input
    4
    2 3 1 0
    Output
    Yes
    

    Initially, $A=(0,0,0,0)$.
    Choosing $i=1$ in operation number $1$ gives $A=(1,1,0,0)$.
    Choosing $i=1$ in operation number $2$ gives $A=(2,2,0,0)$.
    Choosing $i=2$ in operation number $3$ gives $A=(2,3,1,0)$.
    In this way, it has been made equal to the sequence $B$.

    Sample 2
    Input
    3
    1 2 1
    Output
    No
    

    Note that if $A_i$ and $A_{i+1}$ do not have the same parity, you cannot choose $i$.

    Sample 3
    Input
    5
    100 0 100 0 100
    Output
    No
    

    Sample 4
    Input
    5
    3 5 3 2 1
    Output
    No
    

    Sample 5
    Input
    6
    1 2 3 3 2 1
    Output
    Yes
    

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