Codeforces 845 C Two TVs
参考: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 ;
}
Codeforces 845 C Two TVs的更多相关文章
- Codeforces 845 C. Two TVs 思路:简单贪心算法
题目: 题目原文链接:http://codeforces.com/contest/845/problem/C 题意:现在我们有一个电视清单,有两个电视,电视清单上有每一个节目的开始时间和结束时间. 电 ...
- Codeforces 845 A. Chess Tourney 思路:简单逻辑题
题目: 题意:输入一个整数n,接着输入2*n个数字,代表2*n个选手的实力. 实力值大的选手可以赢实力值小的选手,实力值相同则都有可能赢. 叫你把这2*n个选手分成2个有n个选手的队伍. ...
- Codeforces 845 简要题解
文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 A题 传送门 题意:2n2n2n个人下棋,分为两个阵营,每个阵营nnn个人,每个人有一个积分,积分高的能赢积分低的,问如果你可以随意选人,然 ...
- Codeforces 845C. Two TVs 思路:简单贪心算法
题目: 题目原文链接:http://codeforces.com/contest/845/problem/C 题意:现在我们有一个电视清单,有两个电视,电视清单上有每一个节目的开始时间和结束时间. 电 ...
- Codeforces 845D - Two TVs(贪心)
原题链接:http://codeforces.com/problemset/problem/845/D 题意:一个人在驾照考试中,路边有“限速XX”.“没有限速”.“可以超车”.“不能超车”路牌, 以 ...
- http://codeforces.com/contest/845
A. Chess Tourney time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- codeforces 848c - two TVs
2017-08-22 15:42:44 writer:pprp 参考:http://blog.csdn.net/qq_37497322/article/details/77463376#comment ...
- Educational Codeforces Round 27 补题
题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...
- Codeforces 845G Shortest Path Problem?
http://codeforces.com/problemset/problem/845/G 从顶点1dfs全图,遇到环则增加一种备选方案,环上的环不需要走到前一个环上作为条件,因为走完第二个环可以从 ...
随机推荐
- Ext,合计保留两位小数
1. features: [{ ftype: 'summary', dock: 'bottom' }], 2. summaryType: function(records){ return '合计'; ...
- Python3基本数据类型(五、字典)
一.定义 字典是另一种可变容器模型,且可存储任意类型对象. 字典的每个键值(key=>value)对用冒号(:)分割,每个对之间用逗号(,)分割,整个字典包括在花括号中: dic = {key: ...
- 怎样下载YouTube播放列表视频
YouTube上面的视频种类丰富多彩,要是你想利用上面的资源来学习的话,足够你钻研很长时间了.如果你想在YouTube上面学习一门教程,比如Python,通常这些内容一个视频肯定装不下,会分为好多个视 ...
- wireshark抓取本地回环数据包
linux环境下,用tcpdump,可以用-i lo参数抓取环回接口的包.如果服务端和客户端安装在同一台机器上,调试时是很方便的.linux版的wireshark,选取网卡的菜单里也有lo选项,也 ...
- CF498D Traffic Jams in the Land
嘟嘟嘟 题面:有n条公路一次连接着n + 1个城市,每一条公路有一个堵塞时刻a[i],如果当前时间能被a[i]整除,那么通过这条公路需要2分钟:否则需要1分钟. 现给出n条公路的a[i],以及m次操作 ...
- focal loss和retinanet
这个是自己用的focal loss的代码和公式推导:https://github.com/zimenglan-sysu-512/Focal-Loss 这个是有retinanet:https://git ...
- Yii 判断是不是post方式提交的数据
一.在controller里判断提交是不是通过post方式: if(Yii::$app->request->isPost){ return true; }else{ return fals ...
- Docker 安装tomcat7
[root@VM_0_7_centos ~]# docker pull tomcat:7-jre7 [root@VM_0_7_centos ~]# docker run -di --name=tomc ...
- Android学习笔记_JNI hello world
1.需要准备的工具,eclipse,cdt(c++)插件,cygwin(unix)和 android ndk. 在cygwin的etc目录下将ndk的路径引入到profile文件中,可以在cygwin ...
- Android学习笔记_72_Spinner的用法
一.普通 1. <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android= ...