博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces845C(stl)
阅读量:1906 次
发布时间:2019-04-26

本文共 1372 字,大约阅读时间需要 4 分钟。

C. Two TVs
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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·105) — the number of shows.

Each of the next n lines contains two integers li and ri (0 ≤ li < ri ≤ 109) — 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
3 1 2 2 3 4 5
output
YES
input
4 1 2 2 3 2 3 1 2
output
NO
题意:给你n个区间,问你将这些区间分成不相交的个数是否小于等于2(注意:不能有重点)。
思路:先对l排序,用multiset维护不相交区间个数。
代码:
#include
using namespace std;const int maxn=2e5+5;struct node{
int l; int r;}a[maxn];bool cmp(const node &x,const node &y){
return x.l
s; for(int i=0;i
2) puts("NO"); else puts("YES"); } return 0;}

转载地址:http://lincf.baihongyu.com/

你可能感兴趣的文章
【解决错误】ModuleNotFoundError: No module named ‘tqdm‘
查看>>
【解决错误】ModuleNotFoundError: No module named ‘PIL‘
查看>>
【学习笔记】对vanilla的一些个人理解
查看>>
【解决错误】json.decoder.JSONDecodeError: Expecting value: line 11 column 14 (char 82)
查看>>
【解决错误】The size of tensor a (8) must match the size of tensor b (64) at non-singleton dimension 1
查看>>
word文档中实现目录索引中标题加粗,前导符和页码不加粗
查看>>
“学硕” VS “专硕”
查看>>
【NLP学习笔记】知识图谱阅读笔记及其心得
查看>>
【工具使用】新版CSDN-markdown编辑器使用指南
查看>>
《知识图谱》阅读笔记(六)
查看>>
【NLP学习笔记】中文分词(Word Segmentation,WS)
查看>>
【NLP学习笔记】词性标注(Part-of-speech Tagging, POS)
查看>>
【NLP学习笔记】语义角色标注 (Semantic Role Labeling, SRL)
查看>>
《知识图谱》阅读笔记(七)
查看>>
《知识图谱》阅读笔记(九)
查看>>
【超越白皮书7】你需要知道关于ETH2.0的几个事实
查看>>
超越白皮书8:穿云而过的闪电网络
查看>>
AMM做市无常损失对冲分析系列(一)—— 损益及期权对冲模型构建
查看>>
JS中document对象和window对象有什么区别
查看>>
【python练习题】遍历1
查看>>