402201: GYM100694 K Team Rating

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Team Ratingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Alex and Kostya have created their own Codeforces. To draw attention, they decided to hold a contest called Jaguar Turnik Cup. As in VK Cup, only teams consisting of two people can take part, and Alex also banned the teams of only one person. The rating of each person was taken from Codeforces, and the only task remained is to calculate the rating of teams.

After many disputes it was decided to use the following formula: , where is the maximal personal rating in the team, and is the minimal one. Though, it was still unclear what coefficients x and y should be.

After some more disputes everyone agreed that these coefficients should safisfy the following conditions: x + y = 1, x, y ≥ 0. However, the exact values couldn't be chosen, so Alex and Kostya invited their friends to take part in the warm-up contest. There were n teams in total, each team consisted of two people, and the Codeforces rating of each person was known.

The contest has finished successfully, and the creators decided to choose such x and y that the teams in the standings would be sorted by their team rating in non-ascending order. Can they do that?

Input

The first line contains a single integer n (1 ≤ n ≤ 106) — the number of teams took part in the warm-up contest.

The i-th of the following n lines contains two integers ai, bi (1 ≤ ai, bi ≤ 10000) — the personal ratings of the first and the second members of the team on the i-th place.

Output

Write «YES» or «NO» (without quotes) — depending on if it's possible to choose the coefficients as described.

ExamplesInput
3
2106 1946
1955 1859
1778 1669
Output
YES
Input
3
10 2
8 8
9 6
Output
NO

加入题单

上一题 下一题 算法标签: