zoukankan      html  css  js  c++  java
  • codeforces 1304C

    题目链接:https://codeforces.com/problemset/status?my=on

    按时间排序,集合取交集

    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<cmath>
    #include<stack>
    #include<queue>
    using namespace std;
    typedef long long ll;
    
    const int maxn = 200;
    
    int q,n,m;
    
    struct P{
    	int t,l,r;
    }p[maxn]; 
    
    bool cmp(P a,P b){ return a.t < b.t; }
    
    ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }
    
    int main(){
    	q = read();
    	while(q--){
    		n = read(), m = read();
    		int low = m, high = m;
    		
    		for(int i=1;i<=n;++i){ p[i].t = read(), p[i].l = read(), p[i].r = read(); }
    		
    		sort(p+1,p+1+n,cmp);
    		
    		int f = 0;
    		for(int i=1;i<=n;++i){
    			low -= p[i].t - p[i-1].t, high += p[i].t - p[i-1].t;
    			if(low > p[i].r || high < p[i].l){
    				printf("NO
    ");
    				f = 1;
    				break;
    			}
    			low = max(low, p[i].l); high = min(high, p[i].r);
    		}
    		if(!f) printf("YES
    ");
    	}
    	return 0;
    }
    
  • 相关阅读:
    C#windows向窗体传递泛型类
    phoenix与spark整合
    phoenix创建二级索引
    git
    socket详解
    切片
    通过串口读写数据
    Python 跳出多重循环
    Python从json中提取数据
    Python 字典
  • 原文地址:https://www.cnblogs.com/tuchen/p/13818861.html
Copyright © 2011-2022 走看看