THE QUESTION
Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
Withdrawn in the original booklet: “Please skip this question as there is a mistake.” You have obtained two lists a and b, containing n and m elements respectively. For each integer i from 1 to n, you may choose an integer j such that 1 ≤ j ≤ m and set ai := bj - ai at most once. It is possible for ai to become non-positive as a result of this operation. Determine whether a can be sorted in non-decreasing order. Input The first line contains an integer t — the number of test cases. The first line of each test case contains one integer n. The following line of each test case contains n integers a1, a2, …, an The following line of each test case contains one integer b Output For each test case, print “YES” on a new line if it is possible to sort a in non-decreasing order. Otherwise, print “NO” on a new line. Sample Input Sample Output 5 YES 1 1 NO 5 YES 9 NO 3 1 YES 1 4 3 3 4 1 1 4 2 5 6 4 1 5 4 10 5 4 3 1 9 8 7 8 Explanation In the first test case, [5] is already sorted. In the second test case, it can be shown that it is impossible. In the third test case, we can set a3 := bi - a3 = 6 - 2 = 4. The sequence [1, 4, 4, 5] is in nondecreasing order. In the last case, we can apply operations on each index. The sequence becomes [−1, 0, 1] which is in nondecreasing order. Find the output for the following input: 18 8 1 40 10 50 39 12 41 7 51 39 1 1 59 4 2 1 15 14 89 9 1 64 75 9 49 79 94 89 18 16 87 10 1 47 134 194 282 368 459 545 571 645 739 96 4 1 18 77 53 29 50 6 1 76 106 116 188 223 239 91 5 1 72 47 25 11 76 68 3 1 99 17 98 84 7 1 1 9 14 17 22 29 30 10 5 1 84 77 90 64 13 7 6 1 58 75 97 123 139 139 28 5 1 37 89 111 192 235 99 5 1 23 44 54 48 21 42 7 1 1 1 3 15 25 39 47 15 9 1 30 93 89 72 75 83 83 62 85 23 7 1 89 33 24 23 42 48 99 19 4 1 12 21 88 46 75