Submit | All submissions | Best solutions | Back to list |
NITK05 - FRUITS AND VEGETABLE |
John is in a market buying some vegetables and fruits. There are N variety each of Vegetables and fruits available. The price of each different vegetable is stored in integer array A while that of each different fruit is stored in integer array B. Each array containing N integers. The size of the array is <= 1000. The vegetables and fruits are in any order and you can permute the order of the elements in the arrays.
Now for the real question - is there an arrangement of the fruits and vegetables such that price of Ai + Bi >= K for all i where Ai denotes the ith vegetable in the array A, and Bi denotes the ith fruit in the array B. K is the money present in John's Wallet.
Input
The first line contains the an integer T denoting the number of test cases. T test cases follow. Each test case is given in the following format.
The first line contains two integers, N and K. The second line contains N integers separated by a single space, denoting A array. The third line describes B array in a same format.
1 <= T <= 10
1 <= N <= 1000
1 <= K <= 109
0 <= Ai, Bi <= 109
Output
or each test case, if there is such arrangement exists output “YES”, otherwise “NO” (quotes for clarity).
Example
Input: 2 3 10 2 1 3 7 8 9 4 5 1 2 2 1 3 3 3 4 Output: YES NO
Explanation
The first input has 3 elements in array A and array B, we see that the one of the arrangements, 3 2 1 and 7 8 9 has each pair of elements (3 + 7, 2 + 8 and 9 + 1) summing up to 10 and hence the answer is “YES”.
The second input has B array with three 3s. So, we need at least three numbers in A to be greater than 1. As it's not the case, the answer is “NO”.
Added by: | Gaurav Jain |
Date: | 2013-09-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |