#CF845C. Two TVs
Two TVs
题目描述
Polycarp is a great fan of television.
He wrote down all the TV programs he is interested in for today. His list contains shows, -th of them starts at moment and ends at moment .
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 shows. Are two TVs enough to do so?
输入格式
The first line contains one integer ( ) — the number of shows.
Each of the next lines contains two integers and ( 0<=l_{i}<r_{i}<=10^{9} ) — starting and ending time of -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).
题目大意
题目描述
Polycarp 很喜欢看电视。
他写下了他今天所有感兴趣的共 个电视节目。其中第 个电视节目在 时开始, 时结束。
Polycarp 有两个电视。他可以同时在两台电视上看两种不同的节目,但他不能在一台电视上同时看两个不同的节目。如果一个节目结束时另一个节目刚好开始,则他不能在一台电视上看这两个节目。他想看完这 个节目,请问两台电视足够吗?
输入格式
第一行一个正整数 表示电视节目个数。
接下来 行每行两个自然数 ,表示第 个节目开始和结束的时间。
输出格式
一行一个字符串,如果 Polycarp 能用两台电视看完所有节目,输出 YES,否则输出 NO。```
3
1 2
2 3
4 5
YES
4
1 2
2 3
2 3
1 2
NO