title: Minimize Sum Product Two Arrays Permutations Allowed
signature: class Solution {
  
      public Integer minimizeSumProductTwoArraysPermutationsAllowed(ArrayList<Integer> a, ArrayList<Integer> b, Integer n) {
source_py: def minimize_sum_product_two_arrays_permutations_allowed(A, B, n):
      sorted(A)
      sorted(B)
      result = 0
      for i in range(n):
          result += (A[i] * B[((n - i) - 1)])
      return result
source_cpp: int minimize_sum_product_two_arrays_permutations_allowed(vector<int> A, vector<int> B, int n) {
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int result = 0;
    for ( int i = 0;
    i < n;
    i ++ ) result += ( A [ i ] * B [ n - i - 1 ] );
    return result;
  }
question_info.extension: java
question_info.entry_fn_name: minimizeSumProductTwoArraysPermutationsAllowed
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 558, "inputs": {"a": [31, 85], "b": [18, 33], "n": 1}}, {"idx": 1, "outputs": -8900, "inputs": {"a": [22, -6, 84, 70, 84, 6, 28, -74, -14, 68, 22, 90, -10], "b": [2, -48, -36, -4, -22, -98, -74, -92, -72, -4, 48, -32, 94], "n": 6}}, {"idx": 2, "outputs": 1, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], "b": [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 14}}, {"idx": 3, "outputs": 20524, "inputs": {"a": [12, 33, 93, 2, 83, 9, 61, 84, 9, 69, 2], "b": [85, 92, 92, 1, 54, 31, 69, 4, 39, 81, 52], "n": 7}}, {"idx": 4, "outputs": -14428, "inputs": {"a": [-92, -88, -84, -78, -78, -76, -66, -54, -52, -48, -46, -44, -40, -34, -32, -24, -20, -14, -6, -4, 2, 6, 10, 10, 22, 26, 32, 36, 36, 40, 46, 48, 56, 58, 64, 76, 80, 80, 80, 84, 84, 84, 92], "b": [-98, -90, -82, -80, -76, -66, -62, -62, -62, -50, -50, -50, -32, -30, -14, -12, 4, 6, 12, 14, 16, 30, 30, 30, 32, 34, 40, 42, 50, 52, 56, 58, 60, 62, 62, 64, 66, 68, 78, 82, 86, 90, 94], "n": 26}}, {"idx": 5, "outputs": 8, "inputs": {"a": [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0], "b": [0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1], "n": 32}}, {"idx": 6, "outputs": 19298, "inputs": {"a": [4, 6, 6, 20, 22, 23, 26, 39, 40, 47, 50, 68, 68, 70, 73, 77, 80, 82, 85], "b": [2, 3, 15, 21, 22, 26, 35, 37, 37, 38, 57, 59, 62, 63, 64, 76, 81, 85, 91], "n": 17}}, {"idx": 7, "outputs": -10560, "inputs": {"a": [78, 60, -8, 46, -12], "b": [-72, -80, -30, 16, -38], "n": 2}}, {"idx": 8, "outputs": 0, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "b": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 17}}, {"idx": 9, "outputs": 44563, "inputs": {"a": [60, 66, 84, 99, 85, 89, 28, 97, 85, 71, 53, 93, 23, 9, 45, 26, 49, 95, 64, 33, 70, 34, 10, 1, 68, 39, 53, 12], "b": [37, 33, 33, 77, 78, 34, 28, 1, 63, 15, 51, 50, 90, 22, 71, 23, 68, 55, 2, 22, 31, 54, 76, 36, 2, 27, 96, 89], "n": 15}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> a, ArrayList<Integer> b, Integer n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, b, n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(31, 85)), new ArrayList<>(Arrays.asList(18, 33)), 1, 558);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(22, -6, 84, 70, 84, 6, 28, -74, -14, 68, 22, 90, -10)), new ArrayList<>(Arrays.asList(2, -48, -36, -4, -22, -98, -74, -92, -72, -4, 48, -32, 94)), 6, -8900);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1)), new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 14, 1);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(12, 33, 93, 2, 83, 9, 61, 84, 9, 69, 2)), new ArrayList<>(Arrays.asList(85, 92, 92, 1, 54, 31, 69, 4, 39, 81, 52)), 7, 20524);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-92, -88, -84, -78, -78, -76, -66, -54, -52, -48, -46, -44, -40, -34, -32, -24, -20, -14, -6, -4, 2, 6, 10, 10, 22, 26, 32, 36, 36, 40, 46, 48, 56, 58, 64, 76, 80, 80, 80, 84, 84, 84, 92)), new ArrayList<>(Arrays.asList(-98, -90, -82, -80, -76, -66, -62, -62, -62, -50, -50, -50, -32, -30, -14, -12, 4, 6, 12, 14, 16, 30, 30, 30, 32, 34, 40, 42, 50, 52, 56, 58, 60, 62, 62, 64, 66, 68, 78, 82, 86, 90, 94)), 26, -14428);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0)), new ArrayList<>(Arrays.asList(0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1)), 32, 8);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(4, 6, 6, 20, 22, 23, 26, 39, 40, 47, 50, 68, 68, 70, 73, 77, 80, 82, 85)), new ArrayList<>(Arrays.asList(2, 3, 15, 21, 22, 26, 35, 37, 37, 38, 57, 59, 62, 63, 64, 76, 81, 85, 91)), 17, 19298);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(78, 60, -8, 46, -12)), new ArrayList<>(Arrays.asList(-72, -80, -30, 16, -38)), 2, -10560);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 17, 0);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(60, 66, 84, 99, 85, 89, 28, 97, 85, 71, 53, 93, 23, 9, 45, 26, 49, 95, 64, 33, 70, 34, 10, 1, 68, 39, 53, 12)), new ArrayList<>(Arrays.asList(37, 33, 33, 77, 78, 34, 28, 1, 63, 15, 51, 50, 90, 22, 71, 23, 68, 55, 2, 22, 31, 54, 76, 36, 2, 27, 96, 89)), 15, 44563);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> a, ArrayList<Integer> b, Integer n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, b, n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__