#K81817. Taco Delivery Challenge

    ID: 35838 Type: Default 1000ms 256MiB

Taco Delivery Challenge

Taco Delivery Challenge

John is a delivery guy known for his exceptional speed and precision. His task is to deliver multiple packages scattered across a grid city. The city is modeled as an infinite 2D plane. Each package has a delivery destination \( (x, y) \) and a time window \( [t_{start}, t_{end}] \) during which the package must be delivered.

John starts at \( (0,0) \) at time 0 and moves according to the Manhattan distance. That is, the time required to move from \( (x_1, y_1) \) to \( (x_2, y_2) \) is \( |x_1 - x_2| + |y_1 - y_2| \). If John arrives before \( t_{start} \), he waits until \( t_{start} \); however, if he cannot arrive by \( t_{end} \), the delivery fails.

Given one or more test cases, determine whether John can deliver all packages in each test case on time.

inputFormat

Input is provided via standard input (stdin). The input consists of multiple test cases. Each test case begins with an integer ( N ) representing the number of packages. This is followed by ( N ) lines, each containing four numbers: ( x ), ( y ), ( t_{start} ), and ( t_{end} ) separated by spaces. The input terminates with a line that contains -1.

outputFormat

For each test case, output a line of the form "Case i: YES" if John can deliver all packages on time, or "Case i: NO" otherwise where ( i ) represents the test case number starting from 1. The output should be printed to standard output (stdout).## sample

3
1 1 1.0 3.0
2 2 3.0 6.0
3 3 6.0 9.0
-1
Case 1: YES