C. Air Conditioner

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 3 states: off, heating, and cooling. When it’s off, the restaurant’s temperature remains the same. When it’s heating, the temperature increases by 1 in one minute. Lastly, when it’s cooling, the temperature decreases by 1 in one minute. Gildong can change the state as many times as he wants, at any integer minutes. The air conditioner is off initially.Each customer is characterized by three values: titiiililihihiA customer is satisfied if the temperature is within the preferred range at the instant they visit the restaurant. Formally, the iililihihititiGiven 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.InputEach test contains one or more test cases. The first line contains the number of test cases qq1≤q≤5001≤q≤500The first line of each test case contains two integers nnmm1≤n≤1001≤n≤100−109≤m≤109−109≤m≤109nnmmNext, nniititililihihi1≤ti≤1091≤ti≤109−109≤li≤hi≤109−109≤li≤hi≤109titiiililihihi is the upper bound of their preferred temperature range. The preferred temperature ranges are inclusive.The customers are given in non-decreasing order of their visit time, and the current time is 00OutputFor 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).Example
inputCopy4
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
outputCopyYES
NO
YES
NO
NoteIn the first case, Gildong can control the air conditioner to satisfy all customers in the following way:At 00At 22At 5511At 66At 7722At 1010In the third case, Gildong can change the state to heating at 001122In the second and the fourth case, Gildong has to make at least one customer unsatisfied.
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值