No.1990 Candy Boxes
タグ : / 解いたユーザー数 23
作問者 :
milkcoffee
/ テスター :
riano
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$.
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$
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もしくは右上の雲マークをクリックしてアカウントを作成してください。