跳到正文

题解

题解:AT_abc434_c [ABC434C] Flapping Takahashi

angsaide约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年12月1日
收录
2026年8月17日
更新
2026年11月16日
篇幅
约 1 分钟
获赞
1

版本

  1. v1当前

模拟那个时间最高高度和最低高度,看看是否符合要求(具体详见⬇️)。

C++
#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;
}
原文