维护一区间 \([l,r]\)

人按照时间升序

考虑 \((l_i, h_i, t_i)\),当前的所有区间与这个区间取交

推到 \(t_{i+1}\) 时,所有区间的端点向两边扩张即可

注意把空掉的区间删掉

#include <bits/stdc++.h>
using namespace std; const int N = 105;
int q,n,m,t[N],l[N],h[N]; struct interval {
int l,r;
void cut(int ql,int qr) {
l=max(l,ql);
r=min(qr,r);
}
void expand(int t) {
if(l>r) return;
l-=t;
r+=t;
}
} I; signed main() {
ios::sync_with_stdio(false);
cin>>q;
while(q--) {
cin>>n>>m;
for(int i=1;i<=n;i++) {
cin>>t[i]>>l[i]>>h[i];
}
for(int i=1;i<=n;i++) {
for(int j=1;j<i;j++) {
if(t[i]<t[j]) {
swap(t[i],t[j]);
swap(l[i],l[j]);
swap(h[i],h[j]);
}
}
}
I={m,m};
for(int i=1;i<=n;i++) {
I.expand(t[i]-t[i-1]);
I.cut(l[i],h[i]);
}
if(I.l <= I.r) puts("YES");
else puts("NO");
}
}

[CF1304C] Air Conditioner的更多相关文章

  1. Codeforces Round #620 (Div. 2) C. Air Conditioner

    Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to ma ...

  2. Codeforces 1304C. Air Conditioner

    本题直接对每个区间取并,若出现非法区间就是No 否则就是Yes #include<bits/stdc++.h> using namespace std; #define lowbit(x) ...

  3. 日常维护sql

    修复mysqlcheck -u -p --repair  pmdb prefix="/export/data/mysql/bin/mysql -u -p -e" domain=机房 ...

  4. 又是周六了-MySQL特训

    hi 又是周六,又是磨蹭个一上午~午饭后开始吧 1.MySQL -----子查询与连接(三)----- ----使用INSERT...SELECT插入记录 --数据库内容的英文版本 由于我的WAMP中 ...

  5. Correspondence / ˏkɔris'pɔndәns / dictionary10-800.doc

    I have taken courses in office administration, typing,reports and correspondence writing. Correspond ...

  6. 越狱Season 1-Episode 1: the pilot

    the pilot: 美国电视剧新剧开播都会有一个试播来测试观众对新剧的接受程度,以此来决定是否再继续播下去,也可以说是一个开端,第一集,试播 -Tattoo Artist: That's it. t ...

  7. 基于 HTML5 Canvas 的 3D 机房创建

    对于 3D 机房来说,监控已经不是什么难事,不同的人有不同的做法,今天试着用 HT 写了一个基于 HTML5 的机房,发现果然 HT 简单好用.本例是将灯光.雾化以及 eye 的最大最小距离等等功能在 ...

  8. How I explained OOD to my wife(转)

    How I explained OOD to my wife Learning Object Oriented Design principles through interesting conver ...

  9. English trip V2 - 5 Technology Teacher:Taylor Key:adjective + preposition

    In this lesson you will learn to talk about technology and innovation. 课上内容(Lesson) What is your fav ...

随机推荐

  1. Zookeeper分布式协调即分布式锁机制

    主要用到的Zookeeper机制: 临时+有序节点,节点watch机制 过程: 发生分布式锁竞争时,参与竞争的各个客户端服务都到Zookeeper的同一父节点(代表着同一把锁)下建立自己的临时+有序子 ...

  2. appium server与nodeJs 兼容问题

    在命令行模式下启动appium server时报错:error: uncaughtException: Cannot find module 'internal/util/types' 再来看看app ...

  3. 剑指offer-面试题63-股票的最大利润-数组

    /* 题目: 给定一个股价序列,求一次交易的最大利润. */ #include<iostream> #include<vector> using namespace std; ...

  4. Gartner评估:众包将掀起IT服务市场的革命

    国际IT顾问与咨询公司Gartner发布评估报告,称众包是中国的一种新兴业务模式,将掀起IT服务市场的革命.然而,只有很少的的服务提供商会构建众包平台来尝试使用该业务模式.IT服务提供商的业务部门负责 ...

  5. 修改PR Cs6,PS Cs6,AU Cs6的启动界面

    转载来源:https://jingyan.baidu.com/article/09ea3ede00aeedc0aede39ca.html 百度了很多,只见PS Cs6的启动界面修改教程,PR,AU C ...

  6. 安装npm install时,长时间停留在fetchMetadata的解决方法

    安装npm install时,长时间停留在fetchMetadata: sill mapToRegistry uri http://registry.npmjs.org/whatwg-fetch处, ...

  7. 为什么你SQL Server中SQL日期转换出错了呢?

    开发人员有时候使用类似下面SQL将字符串转换为日期时间类型,乍一看,这样的SQL的写法是没有什么问题的.但是这样的SQL其实有时候就是一个定时炸弹,随时可能出现问题(),下面简单对这种情况进行一个简单 ...

  8. idea 编译报错 Build completed with 1 error and 0 warnings in 2 s 113 ms

    settings里java compiler改成正确版本 project structure里同样如此

  9. es的分布式架构原理是什么?

    es的分布式架构原理是什么? 1.首先说一些分片(shard)是什么? ES中所有数据均衡的存储在集群中各个节点的分片中,会影响ES的性能.安全和稳定性 每个shard都是一个最小工作单元,承载部分数 ...

  10. 在腾讯云上配置.NetCoreWeb

    1.购买服务器 2.远程登录(账号密码在上图铃铛里的消息里) 3.安装iis 3.安装.NetCore相关 下载最新版本.NET Core Windows Server Hosting https:/ ...