Submission #71323798


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
bool check(int L1,int R1,int L2,int R2){
    if(L1>L2){swap(L1,L2);swap(R1,R2);}
    return R1>=L2;
}
int main(){
    int t;
    cin >> t;
    while(t--){
        int n,H;
        scanf("%d%d",&n,&H);
        int t=0,Lx=H,Rx=H;
        bool flag=true;
        for(int i=1;i<=n;i++){
            int d,L,R;
            scanf("%d%d%d",&d,&L,&R);
            Lx=max(0,Lx-(d-t));
            Rx+=d-t;
            if(!check(Lx,Rx,L,R)){
                flag=false;
            }
            t=d;
            Lx=max(Lx,L);
            Rx=min(Rx,R);
        }
        if(flag) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Submission Info

Submission Time
Task C - Flapping Takahashi
User Hacker_
Language C++23 (GCC 15.2.0)
Score 300
Code Size 714 Byte
Status AC
Exec Time 26 ms
Memory 3844 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3680 KiB
01_small_00.txt AC 26 ms 3748 KiB
01_small_01.txt AC 22 ms 3708 KiB
01_small_02.txt AC 21 ms 3804 KiB
01_small_03.txt AC 19 ms 3684 KiB
01_small_04.txt AC 17 ms 3700 KiB
01_small_05.txt AC 17 ms 3644 KiB
01_small_06.txt AC 17 ms 3764 KiB
01_small_07.txt AC 16 ms 3844 KiB
02_random_00.txt AC 13 ms 3748 KiB
02_random_01.txt AC 16 ms 3680 KiB
02_random_02.txt AC 16 ms 3744 KiB
02_random_03.txt AC 14 ms 3636 KiB
02_random_04.txt AC 15 ms 3780 KiB
02_random_05.txt AC 15 ms 3680 KiB
02_random_06.txt AC 13 ms 3680 KiB
02_random_07.txt AC 15 ms 3676 KiB
02_random_08.txt AC 16 ms 3644 KiB
02_random_09.txt AC 9 ms 3744 KiB
02_random_10.txt AC 15 ms 3636 KiB
02_random_11.txt AC 15 ms 3748 KiB
02_random_12.txt AC 15 ms 3804 KiB
02_random_13.txt AC 15 ms 3804 KiB
02_random_14.txt AC 15 ms 3808 KiB
02_random_15.txt AC 16 ms 3748 KiB
02_random_16.txt AC 16 ms 3624 KiB
02_random_17.txt AC 16 ms 3804 KiB
02_random_18.txt AC 16 ms 3808 KiB
02_random_19.txt AC 16 ms 3708 KiB