题解:AT_abc434_c [ABC434C] Flapping Takahashi
模拟那个时间最高高度和最低高度,看看是否符合要求(具体详见⬇️)。
#include<bits/stdc++.h>
#define _ 100005
#define ll long long
using namespace std;
ll t;
int main()
{
cin>>t;
while(t--)
{
ll n,h,k=0,flag=0,lo=0;
cin>>n>>h;
ll ne_w=h,w_ne=h;
for(int i=1;i<=n;i++)
{
ll t,tt,ttt;
cin>>t>>tt>>ttt;
ne_w=max(ne_w-(t-lo),tt);//最低高度,取max是因为只能从现飞到的高度开始飞,其一定大于tt
w_ne=min(ttt,w_ne+t-lo);//最高高度,取min是因为只能从现飞到的高度开始飞,其一定小于等于ttt
if(w_ne<tt||ne_w>ttt)
{
flag=1;
//cout<<ne_w;
}
lo=t;
}
if(flag==1)
{
cout<<"No"<<endl;
}
else cout<<"Yes"<<endl;
}
return 0;
}