Timer is Running

Given two arrays of equal size **N** and an integer **K**. The task is to check if after permuting both arrays, we get sum of their corresponding element greater than or equal to k i.e **A _{i} + B_{i} >= K **for i =0 to N-1.

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. Then **T** test cases follow. Each test case contains three lines.The first line of input contains two integers **N** and **K**. Then in the next two lines are space separated elements of the array A and B.

**Output:**

For each test case, print "**1**" (without quotes) if sum is possible(for whole array) else "**0**" (without quotes).

**Constraints:**

1 <= T <= 100

1 <= N <=10^{3}

1 <= K <= 10^{7 }

1 <= A_{i}, B_{i}<= 10^{18}

**Example:
Input:**

2

3 10

2 1 3

7 8 9

4 5

1 2 2 1

3 3 3 4

**Output:**

1

0

**Explanation:
Testcase 1: **K=10 here. A can be written as {1 2 3} and B can be written as {9 8 7} so that for all i A[i]+B[i]>=K

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

abnandi04 | 801 |

KshamaGupta | 412 |

srivastavad270 | 223 |

bhavyapratap56 | 206 |

anshusingh20112001 | 181 |

abnandi04 | 776 |

KshamaGupta | 296 |

srivastavad270 | 223 |

bhavyapratap56 | 206 |

afreensartaj131 | 170 |

blackshadows | 5362 |

Ibrahim Nash | 5244 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4748 |

Login to report an issue on this page.