Logo
(追記) (追記ここまで)

17666번 - Remittance 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB175585233.766%

문제

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).

서브태스크

번호배점제한
115

N ≤ 7, Ai ≤ 5, Bi ≤ 5 (1 ≤ i ≤ N).

240

N ≤ 20.

345

No additional constraints.

예제 입력 1

5
0 0
1 0
2 3
3 3
4 0

예제 출력 1

Yes

For example, by using the remittance service in the following way, you can make the amounts of money equal to the desired amounts of money for all houses.

  1. 2 yen is sent from the House 5 to the House 1. It costs 2 yen.
  2. 1 yen is sent from the House 1 to the House 2. It costs 1 yen.
  3. 1 yen is sent from the House 2 to the House 3. It costs 1 yen.

예제 입력 2

5
0 0
1 2
2 4
3 2
4 0

예제 출력 2

No

You cannot make the amounts of money equal to the desired amounts of money for all houses by using remittance service in any way

예제 입력 3

2
1 1
2 1

예제 출력 3

No

Note that money must be sent in units of 1 yen.

예제 입력 4

2
1 1
2 2

예제 출력 4

Yes

You do not need to use the remittance service.

힌트

출처

Contest > JOI Open Contest > JOI Open Contest 2019 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /