아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Adding Numbers

면접 대비

시간 제한0.5초메모리 제한512 MB

요약
모두 0인 배열에서 시작해 인접한 두 위치에 (1,2) 또는 (2,1)을 더하는 연산만으로 목표 배열 B를 만들 수 있는지 판정한다.
난이도

보통10점 중 5점

유형
그리디, 구현
정답자
아직 제출이 없습니다

문제

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.

예제5

  1. 예제 1

    입력
    6
    1 3 2 0 4 2
    
    예상 출력
    YES
    
  2. 예제 2

    입력
    3
    2 8 2
    
    예상 출력
    YES
    
  3. 예제 3

    입력
    3
    2 2 8
    
    예상 출력
    NO
    
  4. 예제 4

    입력
    5
    0 0 0 0 3
    
    예상 출력
    NO
    
  5. 예제 5

    입력
    5
    0 0 0 0 1
    
    예상 출력
    NO