煤矸石空心砖

联系我们Contact

企业名称:桐城市南口新型建材有限公司

联系人:崔经理

电话:0556-6568069

手机:18156911555

邮箱:303927413@qq.com

地址:桐城市龙腾街道高桥村

网址:   www.nkxxjc.com 



您的当前位置: 首 页 > conditioner是什么 > Codeforces 1304 C. Air Conditioner

Codeforces 1304 C. Air Conditioner

Description:

Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it.

Gildong tries so hard to satisfy the customers that he even memorized all customers’ preferred temperature ranges! Looking through the reservation list, he wants to satisfy all customers by controlling the temperature of the restaurant.

The restaurant has an air conditioner that has Codeforces 1304 C. Air Conditioner_jj states: off, heating, and cooling. When it’s off, the restaurant’s temperature remains the same. When it’s heating, the temperature increases by Codeforces 1304 C. Air Conditioner_jj_02 in one minute. Lastly, when it’s cooling, the temperature decreases by Codeforces 1304 C. Air Conditioner_jj_02

Each customer is characterized by three values: Codeforces 1304 C. Air Conditioner_jj_04 — the time (in minutes) when the i-th customer visits the restaurant, KaTeX parse error: Expected 'EOF', got '}' at position 5: l_[i}̲ — the lower bound of their preferred temperature range, and Codeforces 1304 C. Air Conditioner_jj_05

A customer is satisfied if the temperature is within the preferred range at the instant they visit the restaurant. Formally, the Codeforces 1304 C. Air Conditioner_jj_06 customer is satisfied if and only if the temperature is between Codeforces 1304 C. Air Conditioner_jj_07 and Codeforces 1304 C. Air Conditioner_jj_05 (inclusive) in the Codeforces 1304 C. Air Conditioner_jj_09

Given the initial temperature, the list of reserved customers’ visit times and their preferred temperature ranges, you’re going to help him find if it’s possible to satisfy all customers.

Input

Each test contains one or more test cases. The first line contains the number of test cases Codeforces 1304 C. Air Conditioner_jj_10 Codeforces 1304 C. Air Conditioner_jj_11. Description of the test cases follows.

The first line of each test case contains two integers Codeforces 1304 C. Air Conditioner_jj_12 and Codeforces 1304 C. Air Conditioner_jj_13, where Codeforces 1304 C. Air Conditioner_jj_12

Next, Codeforces 1304 C. Air Conditioner_jj_12 lines follow. The Codeforces 1304 C. Air Conditioner_jj_06 line of them contains three integers Codeforces 1304 C. Air Conditioner_jj_17, and Codeforces 1304 C. Air Conditioner_jj_18, where ti is the time when the Codeforces 1304 C. Air Conditioner_jj_06 customer visits, Codeforces 1304 C. Air Conditioner_jj_07 is the lower bound of their preferred temperature range, and Codeforces 1304 C. Air Conditioner_jj_05

The customers are given in non-decreasing order of their visit time, and the current time is Codeforces 1304 C. Air Conditioner_jj_22.

Output

For each test case, print “YES” if it is possible to satisfy all customers. Otherwise, print “NO”.

You can print each letter in any case (upper or lower).

Exampleinput

4 3 0 5 1 2 7 3 5 10 -1 0 2 12 5 7 10 10 16 20 3 -100 100 0 0 100 -50 50 200 100 100 1 100 99 -100 0

output

YES NO YES NO

Note

In the first case, Gildong can control the air conditioner to satisfy all customers in the following way:

At Codeforces 1304 C. Air Conditioner_jj_23 minute, change the state to heating (the temperature is Codeforces 1304 C. Air Conditioner_jj_24).At Codeforces 1304 C. Air Conditioner_jj_25 minute, change the state to off (the temperature is Codeforces 1304 C. Air Conditioner_jj_26).At Codeforces 1304 C. Air Conditioner_jj_27 minute, change the state to heating (the temperature is Codeforces 1304 C. Air Conditioner_jj_26, the 1-st customer is satisfied).At Codeforces 1304 C. Air Conditioner_jj_29 minute, change the state to off (the temperature is Codeforces 1304 C. Air Conditioner_jj_30).At Codeforces 1304 C. Air Conditioner_jj_31 minute, change the state to cooling (the temperature is Codeforces 1304 C. Air Conditioner_jj_30, the Codeforces 1304 C. Air Conditioner_jj_25At Codeforces 1304 C. Air Conditioner_jj_34 minute, the temperature will be 0, which satisfies the last customer. In the third case, Gildong can change the state to heating at Codeforces 1304 C. Air Conditioner_jj_23

In the second and the fourth case, Gildong has to make at least one customer unsatisfied.

题意:

有n个顾客,0分钟的时候温度是m,每个顾客在第t时候到,他适应的温度为l到r 问是不是能让所有顾客都在适应温度内。 先进行判断,如果同一时间内进入温度区间不相交的话就输出 Codeforces 1304 C. Air Conditioner_jj_36 ,如果相交就缩小区间。 然后通过计算每个人来的时间差,计算出一个温度最大的区间判断是否满足即可。

AC代码:#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define sd(n) scanf("%d", &n)#define sdd(n, m) scanf("%d%d", &n, &m)#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)#define pd(n) printf("%d\n", n)#define pc(n) printf("%c", n)#define pdd(n, m) printf("%d %d\n", n, m)#define pld(n) printf("%lld\n", n)#define pldd(n, m) printf("%lld %lld\n", n, m)#define sld(n) scanf("%lld", &n)#define sldd(n, m) scanf("%lld%lld", &n, &m)#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)#define sf(n) scanf("%lf", &n)#define sc(n) scanf("%c", &n)#define sff(n, m) scanf("%lf%lf", &n, &m)#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)#define ss(str) scanf("%s", str)#define rep(i, a, n) for (int i = a; i = a; i--)#define mem(a, n) memset(a, n, sizeof(a))#define debug(x) cout = mod) ans = ans % mod + mod; } a *= a; if (a >= mod) a = a % mod + mod; b >>= 1; } return ans;}

// 快速幂求逆元int Fermat(int a, int p) //费马求a关于b的逆元{ return qpow(a, p - 2, p);}

///扩展欧几里得ll exgcd(ll a, ll b, ll &x, ll &y){ if (b == 0) { x = 1; y = 0; return a; } ll g = exgcd(b, a % b, x, y); ll t = x; x = y; y = t - a / b * y; return g;}

const int N = 110;

struct node{ ll t, l, r;} a[N];int n, m, cnt;ll L, R, tim, res;int t;bool flag;

int main(){ sd(t); while (t--) { flag = 0; sdd(n, m); rep(i, 1, n) { slddd(a[i].t, a[i].l, a[i].r); } cnt = 1; rep(i, 2, n) { if (a[i].t == a[cnt].t) { if (a[cnt].r < a[i].l || a[i].r < a[cnt].l) { flag = 1; break; } a[cnt].l = max(a[i].l, a[cnt].l); a[cnt].r = min(a[i].r, a[cnt].r); } else a[++cnt] = a[i]; } if (flag == 1) { puts("NO"); continue; } L = m, R = m, res = 0; rep(i, 1, cnt) { tim = a[i].t - res; L = L - tim; R = R + tim; if (R < a[i].l || a[i].r < L) { flag = 1; break; } L = max(L, a[i].l); R = min(R, a[i].r); res = a[i].t; } if (flag == 1) { puts("NO"); continue; } puts("YES"); } return 0;}

本文网址:

关键词:conditioner是什么

相关新闻: