思路
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 15;
struct st{
int t,d,l;
}p[N];
bool check[N];
int n;
bool dfs(int pos,int last)
{
if(pos == n) return true;
for(int i=0;i<n;i++)
{
int t=p[i].t,d = p[i].d, l=p[i].l;
if(!check[i] && t+d >= last)
{
check[i]=true;
if(dfs(pos+1,max(t,last)+l)) return true;//关键
check[i]=false;
}
}
return false;
}
int main()
{
int T;
cin >> T;
while (T -- )
{
cin >> n;
for(int i=0;i<n;i++)
{
int t,d,l;
cin >> t >>d >>l;
p[i]={t,d,l};
}
memset(check, 0, sizeof check);
if(dfs(0,0)) puts("YES");
else puts("NO");
}
return 0;
}