博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Educational Codeforces Round 27-C. Two TVs
阅读量:4114 次
发布时间:2019-05-25

本文共 661 字,大约阅读时间需要 2 分钟。

题意:Polycarp有两台电视,他想看一些电视节目,他知道一些电视开始和结束的时间,现在他想知道有两台电视他能不能播放所有的节目,注意:一个节目结束的时间不能播放其他节目。

思路:把电视节目的开始和结束时间都拆成两个部分,分别标记一些,在根据增序进行排序,遍历结束和开始时间,用一个cnt进行维护,如果出现cnt>2,则不能播放所有的节目。

#include 
using namespace std;const int maxn=4e5+10;struct Node{ int mark; int t;} node[maxn];bool cmp(Node n1,Node n2){ return n1.t
n2.mark);}int main(){ int n; cin>>n; int cnt=0; for(int i=1; i<=n; i++) { int l,r; cin>>l>>r; node[cnt].mark=1; node[cnt++].t=l; node[cnt].mark=-1; node[cnt++].t=r; } int ans=0; sort(node,node+cnt,cmp); for(int i=0; i
2) { cout<<"NO"<

转载地址:http://yfgsi.baihongyu.com/

你可能感兴趣的文章
EntityFramework 学习之一 —— 模型概述与环境搭建 .
查看>>
C# 发HTTP请求
查看>>
启动 LocalDB 和连接到 LocalDB
查看>>
Palindrome Number --回文整数
查看>>
Reverse Integer--反转整数
查看>>
Container With Most Water --装最多水的容器(重)
查看>>
Longest Common Prefix -最长公共前缀
查看>>
Letter Combinations of a Phone Number
查看>>
Single Number II --出现一次的数(重)
查看>>
Valid Parentheses --括号匹配
查看>>
Remove Element--原地移除重复元素
查看>>
Remove Duplicates from Sorted Array--从有序数组中移除重复元素
查看>>
Count and Say
查看>>
Gas Station
查看>>
Palindrome Partitioning --回文切割 深搜(重重)
查看>>
Valid Palindrome 简单的回文判断
查看>>
Pascal's Triangle -- 生成杨辉三角
查看>>
Pascal's Triangle II 生成杨辉三角中的某行
查看>>
Minimum Depth of Binary Tree -- 二叉树的最小深度 DFS 加剪枝
查看>>
Climbing Stairs 爬楼梯方法 动态规划
查看>>