LogiQuest

427. Can Attend All Meetings

EasyIntervalsSorting

Print YES if one person can attend all meetings (a meeting may start exactly when another ends), else NO.

Input format

Line 1: n Next n lines: start end

Output format

YES or NO

Example 1

Input

3
0 30
5 10
15 20

Output

NO

Example 2

Input

2
7 10
2 4

Output

YES

Constraints

1 ≤ n ≤ 10⁴

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…