CF1786B.Cake Assembly Line

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A cake assembly line in a bakery was once again optimized, and now nn cakes are made at a time! In the last step, each of the nn cakes should be covered with chocolate.

Consider a side view on the conveyor belt, let it be a number line. The ii -th cake occupies the segment [aiw,ai+w][a_i - w, a_i + w] on this line, each pair of these segments does not have common points. Above the conveyor, there are nn dispensers, and when a common button is pressed, chocolate from the ii -th dispenser will cover the conveyor segment [bih,bi+h][b_i - h, b_i + h] . Each pair of these segments also does not have common points.

Cakes and dispensers corresponding to the first example.The calibration of this conveyor belt part has not yet been performed, so you are to make it. Determine if it's possible to shift the conveyor so that each cake has some chocolate on it, and there is no chocolate outside the cakes. You can assume that the conveyour is long enough, so the cakes never fall. Also note that the button can only be pressed once.

In the first example we can shift the cakes as shown in the picture.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1051 \le t \le 10^5 ). The description of the test cases follows.

The first line of each test case contains three integers nn , ww , and hh ( 1n1051 \le n \le 10^5 ; 1w,h1051 \le w, h \le 10^5 ; hwh \le w ) — the number of cakes and dispensers, as well as the halfwidths of cakes and segments on which the chocolate is dispensed.

The second line contains nn integers a1a_1 , a2a_2 , ..., ana_n ( 1ai1091 \le a_i \le 10^9 ) — the positions of the cakes centers. It is guaranteed that ai+w<ai+1wa_i + w < a_{i + 1} - w for all ii .

The third line contains nn integers b1b_1 , b2b_2 , ..., bnb_n ( 1bi1091 \le b_i \le 10^9 ) — the positions of the dispensers. It is guaranteed that bi+h<bi+1hb_i + h < b_{i + 1} - h for all ii .

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5 .

输出格式

For each test case output "YES", if it's possible to shift the conveyor in such a way that each cake ends up with some chocolate, and no chocolate is outside the cakes, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

输入输出样例

  • 输入#1

    4
    3 10 5
    65 95 165
    40 65 145
    5 2 1
    1 6 11 16 21
    4 9 14 19 24
    3 3 2
    13 22 29
    5 16 25
    4 4 1
    27 36 127 136
    35 50 141 144

    输出#1

    YES
    YES
    NO
    YES

说明/提示

The first example is shown in the figures in the statement.

In the second example, we can move the conveyor, for example, so that the centers of the cakes are at 4,9,14,19,244, 9, 14, 19, 24 .

In the third example, we can't move the conveyor accordingly.

首页