当前位置:网站首页>Cf1304c air conditioner

Cf1304c air conditioner

2022-06-10 09:33:00 eva_ can(not)survive

Air Conditioner - Luogu icon-default.png?t=M4ADhttps://www.luogu.com.cn/problem/CF1304C

Given initial temperature , Consider maintaining a section of indoor air conditioning, i.e [l-t,r+t] Then modify the temperature range according to the temperature range that the guests adapt to at each time , If it can no longer adapt to the guest's interval, it is NO, Otherwise YES.

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <unordered_map>
#include <cmath>
#include <map>
#include <cctype>
#include <cstdlib>
#include <deque>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int MN = 65005;
const int MAXN = 1e6 + 5;
const int INF = 0x3f3f3f3f;
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) ((x)&(-x))


struct node {
	int t, l, r;
};
node s[MAXN];

inline void solve() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d", &s[i].t, &s[i].l, &s[i].r);
	}
	bool flag = true;
	int l = m, r = m;
	for (int i = 1; i <= n; i++) {
		int d = s[i].t - s[i - 1].t;
		l = max(l - d, s[i].l);
		r = min(r + d, s[i].r);
		if (l > r) {
			flag = false;
			break;
		}
	}
	if (flag)
		printf("YES\n");
	else
		printf("NO\n");
}


int main() {
	int t;
	scanf("%d", &t);
	while (t--)
		solve();
	return 0;
}

原网站

版权声明
本文为[eva_ can(not)survive]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206100927409319.html