#K69102. Reachable Positions
Reachable Positions
Reachable Positions
You are given T test cases. In each test case, there are N people. Each person has a starting position and a target position. A person can only move a maximum distance of D units in one step. For each person i, it is possible to reach the target if and only if
Your task is to determine for each test case whether every person can reach their target position in a single step. If all persons can reach their respective targets then output "YES", otherwise output "NO".
inputFormat
The input is read from stdin and has the following format:
- An integer T, the number of test cases.
- For each test case:
- A single line containing two space-separated integers: N (the number of people) and D (the maximum distance a person can move in one step).
- A line with N space-separated integers representing the starting positions A.
- A line with N space-separated integers representing the target positions B.
outputFormat
For each test case, output a single line to stdout containing either "YES" if every person can reach the target position, or "NO" otherwise.
## sample6
3 2
1 3 5
3 7 7
4 1
1 2 3 4
2 1 4 3
1 0
5
5
2 5
1 10
6 15
3 3
100 200 300
100 204 297
5 10
10 20 30 40 50
20 30 40 50 60
NO
YES
YES
YES
NO
YES
</p>