#include<iostream>
#include<math.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N=10010;
bool vis[N];
int n;int T;
int t[N],d[N],l[N];
bool dfs(int u,int now)
{
if(u==n)
{
return 1;
}
for(int i=0;i<n;i++)
{
if(vis[i]==0&&t[i]+d[i]>=now)
{
vis[i]=1;
if(dfs(u+1,max(now,t[i])+l[i]))
return 1;
vis[i]=0;
}
}
return 0;
}
int main()
{
cin>>T;
while(T--)
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>t[i]>>d[i]>>l[i];
}
if(dfs(0,0))
cout<<"YES";
else
cout<<"NO";
}
return 0;
}
飞机降落 dfs
于 2024-03-27 21:39:43 首次发布