题目描述
Chef is asked to write a program that takes an array A of length N and two integers X, Y as input and modifies it as follows:
Choose a random subset of elements of A (possibly empty)
Increase all the elements of the chosen subset by X
Increase the remaining elements in A by Y
You are given N, X, Y, A and the array B that is returned by Chef's program. Determine whether Chef's program gave the correct output.
------ Input Format ------
- The first line contains an integer T, the number of testcases. The description of the T testcases follow.
- Each testcase contains 3 lines.
- The first line of each testcase contains a three space separated integers N, X, Y respectively.
- The second line of each testcase contains N space separate integers, the elements of the array A.
- The third line of each testcase contains N space separate integers, the elements of the array B.
------ Output Format ------
- For each testcase, print in a single line either yes or no, according to whether Chef's program gave a valid output or not.
- You may output the answers in any case, for example the words Yes, YeS, YES, yES are all considered equivalent to yes.
------ Constraints ------
$1 ≤ T ≤ 10$
$1 ≤ N ≤ 1000$
$0 ≤ X, Y ≤ 1000$
$0 ≤ A_{i} ≤ B_{i} ≤ 1000$ for all indices $i$
------ subtasks ------
Subtask #1 (100 points): original constraints
----- Sample Input 1 ------
3
3 2 5
9 5 1
11 10 3
3 2 5
9 5 1
11 7 3
3 2 5
9 5 1
11 7 7
----- Sample Output 1 ------
Yes
Yes
No
----- explanation 1 ------
Test Case 1: The array $A$ is $\{9, 5, 1\}$. If the chosen elements are $9, 1$ then the expected output would be $\{11, 10, 3\}$, so the answer is yes.
Test Case 2: The array $A$ is $\{9, 5, 1\}$. If the chosen elements are $9, 5, 1$ then the expected output would be $\{11, 7, 3\}$, so the answer is yes.
Test Case 3: The array $A$ is $\{9, 5, 1\}$. There is no subset that can be chosen so that the expected output would be $\{11, 7, 7\}$, so Chef's implementation must be incorrect and the answer is no.
输入格式
见题面
输出格式
见题面