CF845C.Two TVs
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
波利卡普非常喜爱电视。
他写下了今天所有他感兴趣的电视节目。他的列表中包含 n 个节目,其中第 i 个节目从时刻 li 开始,在时刻 ri 结束。
波利卡普拥有两台电视机。他可以同时用这两台电视机观看两个不同的节目,但每台电视机在任意时刻最多只能播放一个节目。如果某个节目在时刻 t 结束,而另一个节目恰好也在时刻 t 开始,则这两个节目不能安排在同一台电视上观看。
波利卡普希望看完全部 n 个节目。仅用两台电视机是否足够?
输入格式
The first line contains one integer n (1 ≤ n ≤ 2·105) — the number of shows.
Each of the next n lines contains two integers l__i and r__i (0 ≤ l__i < r__i ≤ 109) — starting and ending time of i-th show.
第一行包含一个整数 n(1≤n≤2⋅105)—— 表示节目的数量。
接下来的 n 行,每行包含两个整数 li 和 ri(0≤li<ri≤109)—— 分别表示第 i 个节目的开始时间和结束时间。
输出格式
If Polycarp is able to check out all the shows using only two TVs then print "YES" (without quotes). Otherwise, print "NO" (without quotes).
如果波利卡普仅使用两台电视就能观看完所有节目,则输出 “YES”(不带引号);否则,输出 “NO”(不带引号)。
输入输出样例
输入#1
3 1 2 2 3 4 5
输出#1
YES
输入#2
4 1 2 2 3 2 3 1 2
输出#2
NO
输入解题思路,AI测评打分。不知道怎么写?