参考:https://blog.csdn.net/xjh_shin/article/details/77491693

 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
const int N=*1e5+;
struct node
{
int s,e;//s为开始时间,e为结束时间
}no[N];
int cmp(struct node x,struct node y)//应该先按开始时间排序,再按结束时间排序!
{
if (x.s==y.s)
{
return x.e<y.e;
}
return x.s<y.s;
}
void test()
{
for (int i=;i<n;i++)
{
printf("%d %d\n",no[i].s,no[i].e);
}
getchar();
}
int main()
{
// freopen("btext.txt","r",stdin);
while (cin>>n)
{
for (int i=;i<n;i++)
{
cin>>no[i].s>>no[i].e;
}
if (n<)
{
cout<<"YES"<<endl;
continue;
}
sort(no,no+n,cmp);
// test();//提交前要记得注释测试语句!
int flag,ta,tb;
ta=no[].e;
tb=no[].e;
flag=;//已看的节目数量
for (int i=;i<n;i++)
{
if (ta<no[i].s)
{
flag++;
if (flag==n)
{
cout<<"YES"<<endl;
break;
}
ta=no[i].e;
continue;
}
if (tb<no[i].s)
{
flag++;
if (flag==n)
{
cout<<"YES"<<endl;
break;
}
tb=no[i].e;
continue;
}
cout<<"NO"<<endl;
break;
}
} return ;
}

最新文章

  1. 安卓开发之ListAdapter(二)
  2. MFC操作注册表
  3. 【多线程】java多线程 测试例子 详解wait() sleep() notify() start() join()方法 等
  4. 使用git status快速commit
  5. JavaScript toFixed 用法
  6. XE6 &amp; IOS开发之免证书真机调试(1):颁发属于自己的App签名证书(有图有真相)
  7. c# 列举所有窗口和子窗口
  8. 用css3绘制你需要的几何图形
  9. [C++] socket -9[匿名管道]
  10. Asp.net 访问数据库的几种方式
  11. Creating a Mono 3 RPM on CentOS
  12. delphi 常用属性+方法+事件+代码+函数
  13. GitHub使用教程for Eclipse
  14. 深入浅出Node.js (附录B) - 调试Node
  15. AngularJs中文社区学习资料
  16. jquery.validate 一些技巧
  17. ntity Framework技巧系列之四 - Tip 13 – 15
  18. MVC3 项目总结
  19. 假设检验,alpha,p值 通俗易懂的的理解。
  20. php常用的安全过滤函数

热门文章

  1. docker nginx 反向代理
  2. Vim直接打开Tampermonkey网址的方法。
  3. 转贴:天然VC的迷局
  4. oozie说明(本文参考多处,自己留看)
  5. STL容器及算法题:删除奇数的QQ号
  6. ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(六)之 好友申请、同意、拒绝
  7. Python-time和datetime模块
  8. 正则匹配之replace方法
  9. UML 类关系图(泛化,实现,依赖,关联(聚合,组合))
  10. 火狐 SSL 收到了一个弱临时 Diffie-Hellman 密钥