Codeforces 1304C. Air Conditioner
2024-10-08 12:57:19
本题直接对每个区间取并,若出现非法区间就是No 否则就是Yes
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL; LL t[], l[], h[]; void run_case() {
int n;
LL m;
cin >> n >> m;
for(int i = ; i <= n; ++i) cin >> t[i] >> l[i] >> h[i];
LL Left = m, Right = m;
for(int i = ; i <= n; ++i) {
LL times = t[i] - t[i-];
Left = max(l[i], Left-times);
Right = min(h[i], Right+times);
if(Left > Right) {
cout << "NO\n";
return;
}
}
if(Left <= Right) cout << "YES\n";
else cout << "NO\n";
} int main() {
ios::sync_with_stdio(false), cin.tie();
//cout.setf(ios_base::showpoint);cout.precision(10);
int t; cin >> t;
while(t--)
run_case();
cout.flush();
return ;
}
最新文章
- SVN Client
- UEFI安装Kali Linux 1.1.0记录
- 获取shell脚本自身所在目录的Shell脚本分享
- ahjesus根据身份证号码获取相关信息(生日,省市县,性别)
- postgresql 锁的定位
- J2EE事务
- mapper配置
- JSP学习笔记2
- iOS 后台运行实现 --备用
- 离线安装maven
- VB.NET版机房收费系统---SqlHelper
- git修改最后一次commit的内容
- java基础语法(标识符 修饰符 关键字)
- 使用 Mutex 实现进程间同步
- 接口测试-webservice接口---soapui
- sourceTree跳过注册
- 循序渐进学.Net Core Web Api开发系列【0】:序言与目录
- xcode调试查看变量的值
- jmeter测试计划配置
- Sqlserver数据库还原.bak文件失败的两个问题