General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
71159455 Contestant:
snafkin
1304C - 23 GNU C++11 Wrong answer on pretest 3 15 ms 0 KB 2020-02-15 17:40:17 2020-02-15 17:40:18
 
 
→ Source
#include <cstdio>
#include <algorithm>
using namespace std;
struct Customer{
    int time,low,hi;
    bool operator< ( const Customer &c )const
        {
            return time < c.time;
        }
}Cust;
Customer cus[105];
int n,temp,t;
int main() {
    scanf("%d",&t);
    while(t--){
        scanf("%d %d",&n,&temp);
        for(int i=0; i<n; i++){
            scanf("%d %d %d",&cus[i].time,&cus[i].low,&cus[i].hi);
        }
        sort(cus,cus+n);
        int i,time=0,lowestT=temp,highestT=temp;
        for( i=0; i<n; i++){

            if(cus[i].low <=highestT && cus[i].hi>=lowestT){
                highestT = highestT+(cus[i].time-time);
                lowestT = lowestT - (cus[i].time-time);
                time = cus[i].time;
            }else
            if(cus[i].low >= highestT){
                if(highestT+(cus[i].time-time)< cus[i].low)
                    break;
                else{
                    //temp = cus[i].low;
                    highestT = highestT+(cus[i].time-time);
                    lowestT = cus[i].low;
                    time = cus[i].time;
                }
            } else if(cus[i].hi <= lowestT) {
                if(lowestT-(cus[i].time-time)> cus[i].hi)
                    break;
                else{
                    lowestT = lowestT-(cus[i].time-time);
                    highestT = cus[i].low;
                    //temp = cus[i].hi;
                    time = cus[i].time;
                }
            }
            //printf("pass i:%d ,time%d\n",i,time);
        }
        //    printf("%d %d %d\n",cus[i].time,cus[i].low,cus[i].hi);
        if(i==n)
            printf("YES\n");
        else
            printf("NO\n");

        //printf("\n");
    }
    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details