参考: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的更多相关文章

  1. Codeforces 845 C. Two TVs 思路:简单贪心算法

    题目: 题目原文链接:http://codeforces.com/contest/845/problem/C 题意:现在我们有一个电视清单,有两个电视,电视清单上有每一个节目的开始时间和结束时间. 电 ...

  2. Codeforces 845 A. Chess Tourney 思路:简单逻辑题

    题目: 题意:输入一个整数n,接着输入2*n个数字,代表2*n个选手的实力.    实力值大的选手可以赢实力值小的选手,实力值相同则都有可能赢.    叫你把这2*n个选手分成2个有n个选手的队伍. ...

  3. Codeforces 845 简要题解

    文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 A题 传送门 题意:2n2n2n个人下棋,分为两个阵营,每个阵营nnn个人,每个人有一个积分,积分高的能赢积分低的,问如果你可以随意选人,然 ...

  4. Codeforces 845C. Two TVs 思路:简单贪心算法

    题目: 题目原文链接:http://codeforces.com/contest/845/problem/C 题意:现在我们有一个电视清单,有两个电视,电视清单上有每一个节目的开始时间和结束时间. 电 ...

  5. Codeforces 845D - Two TVs(贪心)

    原题链接:http://codeforces.com/problemset/problem/845/D 题意:一个人在驾照考试中,路边有“限速XX”.“没有限速”.“可以超车”.“不能超车”路牌, 以 ...

  6. http://codeforces.com/contest/845

    A. Chess Tourney time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  7. codeforces 848c - two TVs

    2017-08-22 15:42:44 writer:pprp 参考:http://blog.csdn.net/qq_37497322/article/details/77463376#comment ...

  8. Educational Codeforces Round 27 补题

    题目链接:http://codeforces.com/contest/845 A. Chess Tourney 水题,排序之后判断第n个元素和n+1个元素是不是想等就可以了. #include < ...

  9. Codeforces 845G Shortest Path Problem?

    http://codeforces.com/problemset/problem/845/G 从顶点1dfs全图,遇到环则增加一种备选方案,环上的环不需要走到前一个环上作为条件,因为走完第二个环可以从 ...

随机推荐

  1. Bootstrap后台管理模板调研

    Bootstrap后台管理模板调研 SB Admin 2(推荐) SB Admin 2是一款开源的基于Bootstrap搭建的后台管理模板,简约,易用.没有复杂的组件和花炫的设计,很质朴,但较为美观. ...

  2. 如何杀掉一个用户下的所有进程并drop掉这个用户

    如何杀掉一个用户下的所有进程并drop掉这个用户 Copy the sample code below into a file named kill_drop_user.sql.Open SQL*Pl ...

  3. March 20 2017 Week 12 Monday

    A goal is a dream with a deadline. 目标就是给梦想一个期限. Dream without dealine is just daydream, because you ...

  4. 第一次团队Scrum

                                    长大一条龙之成绩查询 一.项目介绍             本项目的意义在于锻炼团队的scrum能力,加强团队合作能力.确定本项目采用的 ...

  5. Jmeter入门10 jmeter加密串处理方式2:BeanShell PreProcessor

    上一个博客讲了方式一:函数助手__digest加密,BeanShell PreProcessor也可以用java代码进行处理 线程组.参数.请求都直接使用上一个博客的. 第一步 添加BeanShell ...

  6. POJ-3104 Drying---二分答案判断是否可行

    题目链接: https://cn.vjudge.net/problem/POJ-3104 题目大意: 有一些衣服,每件衣服有一定水量,有一个烘干机,每次可以烘一件衣服,每分钟可以烘掉k滴水.每件衣服每 ...

  7. hdu1215 七夕节---因子和

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1215 题目大意: 求N的因子和(不包括N本身) 解题思路: 模板传送门 #include<io ...

  8. 【SNOI2017】炸弹

    题目大意 在一条直线上有\(N\)个炸弹,每个炸弹的坐标是\(X_i\),爆炸半径是 \(R_i\), 当一个炸弹爆炸时,如果另一个炸弹所在位置\(X_j\)满足: $ X_i-R_i\leq X_j ...

  9. U3

    一个项目里面可以有多个Activity AndroidManifest.xml<intent-filter> <action android:name="android.i ...

  10. 论文翻译:XNOR-Net: ImageNet Classification Using BinaryConvolutional Neural Networks

    目录 Abstract 1 Introduction 2 Related Work 3 Binary Convolutional Neural Network 3.1 Binary-Weight-Ne ...