@@ -0,0 +1,1014 @@
+import java.io.*;%0Aimport java.util.*;%0Aimport java.text.*;%0Aimport java.math.*;%0Aimport java.util.regex.*;%0A%0Apublic class Solution %7B%0A  // You can also solve this problem by doing global Math.min between 3 situations (one-liner):%0A  // 1. buying black and white for their prices%0A  // 2. buying black for their price and white for black price and convert black to white%0A  // 3. vice versa%0A  private static long minimizeCost(long b, long w, long x, long y, long z) %7B%0A    boolean convert = Math.abs(x - y) %3E z;%0A    if (!convert) return b * x + w * y;%0A    if (x %3E y) %7B%0A      return w * y + b * (y + z);%0A    %7D else %7B%0A      return b * x + w * (x + z);%0A    %7D%0A  %7D%0A%0A  public static void main(String%5B%5D args) %7B%0A    Scanner in = new Scanner(System.in);%0A    int t = in.nextInt();%0A    for(int a0 = 0; a0 %3C t; a0++)%7B%0A      long b = in.nextLong();%0A      long w = in.nextLong();%0A      long x = in.nextLong();%0A      long y = in.nextLong();%0A      long z = in.nextLong();%0A%0A      System.out.println(minimizeCost(b, w, x, y, z));%0A    %7D%0A  %7D%0A%7D%0A

add solution taum-and-bday