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全图,遇到环则增加一种备选方案,环上的环不需要走到前一个环上作为条件,因为走完第二个环可以从 ...
随机推荐
- Selenium2学习(十一)-- select下拉框
本篇以百度设置下拉选项框为案例,详细介绍select下拉框相关的操作方法. 一.认识select 1.打开百度-设置-搜索设置界面,如下图所示 2.箭头所指位置,就是select选项框,打开页面 ...
- IOS MapKit框架的使用(专门用于地图显示)
● MapKit框架使用前提 ● 导入框架 ● 导入主头文件#import <MapKit/MapKit.h> ● MapKit框架使用须知 ● MapKit框架中所有数据类型的前 ...
- Python 变量交换
# coding = utf-8 a, b = 1, 2 print 'before change' print a, b a, b = b, a print 'after change' print ...
- Python:dict字典
#字典dict------->唯一的映射类型 1.数据类型的划分 数据类型划分为可变数据类型和不可变数据类型. 不可变数据类型:tupe(元组).bool.int.str 可 ...
- 数字游戏II
题面好难找:嘟嘟嘟 贪心 + dp. 首先要按bi的降序排序,让每一次减少大的数尽量靠前.为啥咧?于是我们就需要证明:令sum = a1 - (1 - 1) * b1 + a2 - (2 - 1) * ...
- 【Elasticsearch】搜索小记之 match VS match_phrase
最近稍微研究了一下ElasticSearch(下文简称ES),所谓可扩展的开源弹性搜索解决方案,跟同事笑称,如果它作为SQL SERVER的话,我的了解还在基本的select语句上,当然学习它也是一个 ...
- maven学习记录四——私服 nexus
8 私服 nexus 安装nexus 启动服务 启动失败的解决方法: 登录nexus 用户名/密码 admin/admin123 仓库类型 Virtual 虚拟仓库 Proxy 代 ...
- Notepad++正则表达式使用
推荐个正则表达式在线测试的工具http://ccmpp.com/Regex/ Notepad++正则表达式使用 -- ::| 分类: 文档 | 标签:正则表达式 替换 notepad++ 匹配 查找 ...
- JVM 监控以及内存分析
1 内存分析1.1 jmap -histo 命令pid=`jps | awk '{if ($2 == "Jps") print $1}'`jmap -histo $pid > ...
- 使用带有字符串的data-ng-bind
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...