Adding Numbers
면접 대비시간 제한0.5초메모리 제한512 MB
모두 0인 배열에서 시작해 인접한 두 위치에 (1,2) 또는 (2,1)을 더하는 연산만으로 목표 배열 B를 만들 수 있는지 판정한다.
문제
Samouel has an array A of N integers indexed from 1 to N. Initially, all of the integers are 0. His friend, Gregor also has an array B of N integers indexed from 1 to N.
Samouel wants to modify his array such that his array becomes equal to Gregor's. To achieve that, Samouel can apply the following operation: choose two consecutive indices i and i + 1 (1 ≤ i < N) and do either the following:
- Increment Ai by 1 and increment A**i+1 by 2, or
- Increment Ai by 2 and increment A**i+1 by 1.
Determine whether it is possible for Samouel to achieve his goal.
입력
The first line contains one integer: N (1 ≤ N ≤ 100) in a line denoting the length of both array A and B. The second line contains N integers: B1, B2, ..., BN (0 ≤ Bi ≤ 50,000) in a line denoting the value of array B.
출력
Output “YES" in a line if it is possible for Samouel to achieve his goal, or "NO" otherwise.