Codeforces 1304C. Air Conditioner

Posted gredcomet

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces 1304C. Air Conditioner相关的知识,希望对你有一定的参考价值。

本题直接对每个区间取并,若出现非法区间就是No 否则就是Yes

技术图片
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

LL t[105], l[105], h[105];

void run_case() {
    int n;
    LL m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> t[i] >> l[i] >> h[i];
    LL Left = m, Right = m;
    for(int i = 1; i <= n; ++i) {
        LL times = t[i] - t[i-1];
        Left = max(l[i], Left-times);
        Right = min(h[i], Right+times);
        if(Left > Right) {
            cout << "NO
";
            return;
        }
    }
    if(Left <= Right) cout << "YES
";
    else cout << "NO
";
}
 
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //cout.setf(ios_base::showpoint);cout.precision(10);
    int t; cin >> t;
    while(t--)
    run_case();
    cout.flush();
    return 0;
}
View Code

 

以上是关于Codeforces 1304C. Air Conditioner的主要内容,如果未能解决你的问题,请参考以下文章

[CF1304C] Air Conditioner

junto con las conocidas zapatillas Nike Air flow Glide Age

Codeforces 1304B. Longest Palindrome

Codeforces 1304D. Shortest and Longest LIS

Codeforces Round #731 (Div. 3) E. Air Conditioners

Codeforces Round #620 Div2C Air Conditioner