#include<bits/stdc++.h>
using namespace std;
struct air{
int t;
int d;
int l;
bool used;
};
air plane[10];
bool canfly;
void DFS(int n, int t, int cnt){
int nextt;
for(int i = 0; i < n; i++){
if(plane[i].used) continue;//排除飞过的
if(t > (plane[i].t + plane[i].d)) break;//如果时间已经超过某架飞机的落地极限,循环直接结束
if(plane[i].t > t) nextt = plane[i].t;//如果下一个飞机还没到,就直接跳到下个飞机来的时间
else nextt = t;
plane[i].used = true;
DFS(n, nextt + plane[i].l, cnt + 1);
plane[i].used = false;
}
if(cnt == n) canfly = true;
}
int main(){
int t;
cin>>t;
for(int i = 0; i < t; i++){
int n;
cin>>n;
canfly = false;
for(int j = 0; j < n; j++){
cin>>plane[j].t>>plane[j].d>>plane[j].l;
plane[j].used = false;
}
DFS(n, 0, 0);
if(canfly) printf("YES\n");
else printf("NO\n");
}
}
0 回复
0 转发
0 喜欢
8 阅读



