Remittance

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

요약
집들이 원형으로 배치되어 다음 집으로 돈을 보낼 때 같은 금액의 수수료를 내야 할 때, 모든 집을 목표 금액으로 만들 수 있는지 판정한다.
난이도

보통10점 중 7점

유형
그리디, 수학, 구현, 시뮬레이션
정답자
아직 제출이 없습니다

문제

There exist N houses around Beaver Lake in JOI Kingdom, numbered from 1 to N counterclockwisely.

Each house can send money to the left adjoint house in a view from the lake (for the House i (1 ≤ i ≤ N − 1), it is the House i+1 and for the House N, it is the House 1.) by using the remittance service. However, it costs money which is the same amount as the sent money. Money must be sent in units of 1 yen. When you send money, you must pay the fee, so the sum of sent money and fee cannot exceed the amount of money in the house.

Currently, the House i (1 ≤ i ≤ N) has Ai yen. On the other hand, it is desired in the point of view of tax measures that the amount of money in the House i is equal to Bi yen. By using the remittance service, you want to make the amount of money in the House i equal to Bi yen. You cannot spend money on the other thing than fee or send money by the other way than the remittance service.

Write a program which, given the current amounts of money and the desired amounts of money for all houses, decide if you can make the amounts of money equal to the desired amounts of money for all houses by using the remittance service.

입력

Read the following data from the standard input.

N
A1 B1
.
.
.
AN BN

출력

Output Yes if you can make the amounts of money equal to the desired amounts of money for all houses by using the remittance service, No if it is impossible.

제한

  • 2 ≤ N ≤ 1 000 000.
  • 0 ≤ Ai ≤ 1 000 000 000 (1 ≤ i ≤ N).
  • 0 ≤ Bi ≤ 1 000 000 000 (1 ≤ i ≤ N).

예제4

  1. 예제 1

    입력
    5
    0 0
    1 0
    2 3
    3 3
    4 0
    
    예상 출력
    Yes
    
  2. 예제 2

    입력
    5
    0 0
    1 2
    2 4
    3 2
    4 0
    
    예상 출력
    No
    
  3. 예제 3

    입력
    2
    1 1
    2 1
    
    예상 출력
    No
    
  4. 예제 4

    입력
    2
    1 1
    2 2
    
    예상 출력
    Yes