Codeforces 845 C Two TVs
2024-08-24 11:32:37
参考: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 ;
}
最新文章
- 安卓开发之ListAdapter(二)
- MFC操作注册表
- 【多线程】java多线程 测试例子 详解wait() sleep() notify() start() join()方法 等
- 使用git status快速commit
- JavaScript toFixed 用法
- XE6 &; IOS开发之免证书真机调试(1):颁发属于自己的App签名证书(有图有真相)
- c# 列举所有窗口和子窗口
- 用css3绘制你需要的几何图形
- [C++] socket -9[匿名管道]
- Asp.net 访问数据库的几种方式
- Creating a Mono 3 RPM on CentOS
- delphi 常用属性+方法+事件+代码+函数
- GitHub使用教程for Eclipse
- 深入浅出Node.js (附录B) - 调试Node
- AngularJs中文社区学习资料
- jquery.validate 一些技巧
- ntity Framework技巧系列之四 - Tip 13 – 15
- MVC3 项目总结
- 假设检验,alpha,p值 通俗易懂的的理解。
- php常用的安全过滤函数
热门文章
- docker nginx 反向代理
- Vim直接打开Tampermonkey网址的方法。
- 转贴:天然VC的迷局
- oozie说明(本文参考多处,自己留看)
- STL容器及算法题:删除奇数的QQ号
- ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(六)之 好友申请、同意、拒绝
- Python-time和datetime模块
- 正则匹配之replace方法
- UML 类关系图(泛化,实现,依赖,关联(聚合,组合))
- 火狐 SSL 收到了一个弱临时 Diffie-Hellman 密钥