微信开发中 ACCESS TOKEN 过期失效的解决方案详解
726
2022-10-04
Codeforces 845 C. Two TVs (模拟)
Description
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 li and ends at moment ri.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?
Input
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 li and ri (0 ≤ li < ri ≤ 10^9) — starting and ending time of i-th show.
Output
If Polycarp is able to check out all the shows using only two TVs then print “YES” (without quotes). Otherwise, print “NO” (without quotes).
Examples input
31 22 34 5
Examples output
YES
题意
给定所有电视节目的播放时间,有两台电视,问能否完整收看所有的电视节目。(同一个电视无法完整收看两个连续时间的节目)
思路
模拟出两台电视观看节目的结束时间,然后排序枚举一遍所有的节目即可。
AC 代码
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~