Two TVs

题意翻译

#### 题目描述 Polycarp 很喜欢看电视。 他写下了他今天所有感兴趣的共 $n\,(1 \le n \le 2 \times 10^5)$ 个电视节目。其中第 $i$ 个电视节目在 $l_i$ 时开始, $r_i$ 时结束。 $\,(0 \le l_i, r_i \le 10^9)$ Polycarp 有两个电视。他可以同时在两台电视上看两种不同的节目,但他不能在一台电视上同时看两个不同的节目。如果一个节目结束时另一个节目刚好开始,则他不能在一台电视上看这两个节目。他想看完这 $n$ 个节目,请问两台电视足够吗? #### 输入格式 第一行一个正整数 $n$ 表示电视节目个数。 接下来 $n$ 行每行两个自然数 $l_i, r_i$,表示第 $i$ 个节目开始和结束的时间。 #### 输出格式 一行一个字符串,如果 Polycarp 能用两台电视看完所有节目,输出 `YES`,否则输出 `NO`。```

题目描述

Polycarp is a great fan of television. He wrote down all the TV programs he is interested in for today. His list contains $ n $ shows, $ i $ -th of them starts at moment $ l_{i} $ and ends at moment $ r_{i} $ . Polycarp owns two TVs. He can watch two different shows simultaneously with two TVs but he can only watch one show at any given moment on a single TV. If one show ends at the same moment some other show starts then you can't watch them on a single TV. Polycarp wants to check out all $ n $ shows. Are two TVs enough to do so?

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 1<=n<=2·10^{5} $ ) — the number of shows. Each of the next $ n $ lines contains two integers $ l_{i} $ and $ r_{i} $ ( $ 0<=l_{i}&lt;r_{i}<=10^{9} $ ) — starting and ending time of $ i $ -th show.

输出格式


If Polycarp is able to check out all the shows using only two TVs then print "YES" (without quotes). Otherwise, print "NO" (without quotes).

输入输出样例

输入样例 #1

3
1 2
2 3
4 5

输出样例 #1

YES

输入样例 #2

4
1 2
2 3
2 3
1 2

输出样例 #2

NO