There exist
Each house can send money to the left adjoint house in a view from the lake (for the House
Currently, the House
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.
Input Specification
Read the following data from the standard input.
Output Specification
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.
Constraints
. . .
Subtasks
- (15 points)
, , . - (40 points)
. - (45 points) No additional constraints.
Sample Input 1
5
0 0
1 0
2 3
3 3
4 0
Sample Output 1
Yes
Explanation for Sample 1
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.
yen is sent from the House to the House . It costs yen. yen is sent from the House to the House . It costs yen. yen is sent from the House to the House . It costs yen.
Sample Input 2
5
0 0
1 2
2 4
3 2
4 0
Sample Output 2
No
Explanation for Sample 2
You cannot make the amounts of money equal to the desired amounts of money for all houses by using remittance service in any way.
Sample Input 3
2
1 1
2 1
Sample Output 3
No
Explanation for Sample 3
Note that money must be sent in units of
Sample Input 4
2
1 1
2 2
Sample Output 4
Yes
Explanation for Sample 4
You do not need to use the remittance service.
Comments