public class Solution {
  public static void main(String[] args) throws Exception {
    
  }
}

@@ -1,92 +1,1998 @@
-public class Solution %7B%0A  public static void main(String%5B%5D args) throws Exception %7B%0A    
+import java.io.*;%0Aimport java.util.Arrays;%0Aimport java.util.StringTokenizer;%0A%0A/**%0A * @author shengmin%0A */%0Apublic class Solution %7B%0A  boolean solve(int%5B%5D A, int%5B%5D B, int K) %7B%0A    Arrays.sort(A);%0A    Arrays.sort(B);%0A    int pivot = B.length;%0A    int capacity = 0;%0A%0A    for (int i = 0; i %3C A.length; i++) %7B%0A      int a = A%5Bi%5D;%0A      int newPivot = binarySearch(B, a, K, 0, pivot);%0A      if (newPivot == -1) %7B%0A        if (--capacity %3C 0) %7B%0A          return false;%0A        %7D%0A      %7D else %7B%0A        capacity += pivot - newPivot - 1;%0A        pivot = newPivot;%0A      %7D%0A    %7D%0A%0A    return true;%0A  %7D%0A%0A  int binarySearch(int%5B%5D B, int a, int K, int start, int end) %7B%0A    int answer = -1;%0A    while (start %3C end) %7B%0A      int midIndex = start + (end - start) / 2;%0A      int mid = B%5BmidIndex%5D;%0A      if (mid + a %3E= K) %7B%0A        answer = midIndex;%0A        end = midIndex;%0A      %7D else %7B%0A        start = midIndex + 1;%0A      %7D%0A    %7D%0A    return answer;%0A  %7D%0A%0A  void run(BufferedReader rd) throws Exception %7B%0A    PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));%0A    int T = Integer.parseInt(rd.readLine());%0A    for (int i = 0; i %3C T; i++) %7B%0A      StringTokenizer st = new StringTokenizer(rd.readLine());%0A      int N = Integer.parseInt(st.nextToken());%0A      int K = Integer.parseInt(st.nextToken());%0A%0A      int%5B%5D A = new int%5BN%5D;%0A      int%5B%5D B = new int%5BN%5D;%0A      st = new StringTokenizer(rd.readLine());%0A      for (int j = 0; j %3C N; j++) %7B%0A        A%5Bj%5D = Integer.parseInt(st.nextToken());%0A      %7D%0A      st = new StringTokenizer(rd.readLine());%0A      for (int j = 0; j %3C N; j++) %7B%0A        B%5Bj%5D = Integer.parseInt(st.nextToken());%0A      %7D%0A%0A      pw.println(solve(A, B, K) ? %22YES%22 : %22NO%22);%0A    %7D%0A%0A    rd.close();%0A    pw.close();%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws Exception %7B%0A    BufferedReader rd = args.length %3E 0%0A        ? new BufferedReader(new FileReader(args%5B0%5D))%0A        : new BufferedReader(new InputStreamReader(System.in));%0A    new Solution().run(rd);
 %0A  %7D

Add solution to two-arrays problem