#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,flag,st[N];
struct plane{
int early;
int late;
int t;
}a[N];
void dfs(int x,int now){
if(flag) return;
if(x>n){
flag=1;
cout<<"YES"<<endl;
return;
}
for(int i=1;i<=n;i++){
if(!st[i]){
if(a[i].late<now) return;
st[i]=1;
dfs(x+1,max(a[i].early,now)+a[i].t);
st[i]=0;
}
}
}
int main()
{
int T;
cin>>T;
while(T--){
n=0;
flag=0;
cin>>n;
for(int i=1;i<=n;i++){
int d,b,c;
cin>>d>>b>>c;
a[i].early=d;
a[i].late=d+b;
a[i].t=c;
}
dfs(1,0);
if(!flag) cout<<"NO"<<endl;
}
return 0;
}`
0 回复
0 转发
0 喜欢
9 阅读



