20210716
作者:互联网
时间机器
code
const int N = 5e4+5;
int T,n,m;
struct Node {
int l,r,n;
} a[N],b[N];
bool operator < (const Node &x,const Node &y) { return x.l < y.l; }
struct Rest {
int r;
mutable int n;
Rest(int r=0,int n=0):r(r),n(n){}
};
bool operator < (const Rest &x,const Rest &y)
{ return x.r!=y.r ? x.r<y.r : x.n<y.n; }
set<Rest> s;
void solve() {
read(n,m);
For(i,1,n) read(a[i].l,a[i].r,a[i].n);
For(i,1,m) read(b[i].l,b[i].r,b[i].n);
sort(a+1,a+n+1), sort(b+1,b+m+1);
for(int i = 1, j = 1; i <= n; ++i) {
for(; j <= m && b[j].l <= a[i].l; ++j) s.insert(Rest(b[j].r,b[j].n));
while( a[i].n ) {
auto it = s.lower_bound(Rest(a[i].r,0));
if( it == s.end() ) { puts("No"); return; }
if( it->n > a[i].n ) { it->n -= a[i].n; break; }
a[i].n -= it->n, s.erase(it);
}
}
puts("Yes");
}
signed main() {
read(T);
while( T-- ) {
s.clear();
solve();
}
return 0;
}
标签:Node,const,int,Rest,read,return,20210716 来源: https://www.cnblogs.com/401rk8/p/15022560.html