title: Minimum Cost Make Array Size 1 Removing Larger Pairs
signature: function minimum_cost_make_array_size_1_removing_larger_pairs(a, n)
source_py: def minimum_cost_make_array_size_1_removing_larger_pairs(a, n):
      return ((n - 1) * min(a))
source_cpp: int minimum_cost_make_array_size_1_removing_larger_pairs(vector<int> a, int n) {
    return ( n - 1 ) * ( * min_element(a.begin(), a.end()) );
  }
question_info.entry_fn_name: minimum_cost_make_array_size_1_removing_larger_pairs
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(a, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({1, 2, 3, 4, 7, 8, 10, 10, 16, 20, 22, 22, 23, 23, 23, 27, 29, 32, 35, 39, 41, 46, 51, 53, 54, 59, 59, 60, 61, 69, 70, 70, 79, 79, 81, 84, 90, 91, 98}, 25, 24)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-6, 10}, 1, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 15, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver({20, 61, 92, 45, 75, 26, 83, 5, 85, 27, 39, 88, 36, 39, 83, 41, 56, 77, 39, 69, 72, 98, 39, 15, 29, 69, 64, 92, 96, 49, 59, 62, 53, 82, 40, 37, 29, 41}, 23, 110)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-88, -60, -60, -58, -56, -56, -46, -44, -40, -38, -32, -28, -22, -18, -12, -4, -2, 10, 24, 24, 28, 38, 42, 46, 54, 64, 72, 74, 78, 96, 96}, 26, -2200)
      print(string.format("TEST-4...%s",result))
  
      result = driver({0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1}, 39, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver({1, 4, 6, 9, 10, 12, 17, 17, 18, 21, 22, 26, 26, 31, 32, 33, 34, 39, 42, 43, 45, 46, 48, 50, 53, 53, 54, 55, 60, 61, 62, 63, 63, 64, 70, 70, 70, 71, 71, 78, 86, 88, 91, 92, 95, 95, 96, 97, 99}, 28, 27)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-42, 44, -80, -60, 48, 66, 54, -76, 26, -74, -10, 46, -50, 42, -26, -24, -14, 36, -2, -26, 16, -10, 20, -88, -78}, 19, -1584)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, 5, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver({65, 32, 66, 82, 86, 98, 15, 33, 57, 3, 73, 45, 90, 82, 33, 99, 44, 76, 50, 89, 5, 7, 64}, 22, 63)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 24, "inputs": {"a": [1, 2, 3, 4, 7, 8, 10, 10, 16, 20, 22, 22, 23, 23, 23, 27, 29, 32, 35, 39, 41, 46, 51, 53, 54, 59, 59, 60, 61, 69, 70, 70, 79, 79, 81, 84, 90, 91, 98], "n": 25}}, {"idx": 1, "outputs": 0, "inputs": {"a": [-6, 10], "n": 1}}, {"idx": 2, "outputs": 0, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 15}}, {"idx": 3, "outputs": 110, "inputs": {"a": [20, 61, 92, 45, 75, 26, 83, 5, 85, 27, 39, 88, 36, 39, 83, 41, 56, 77, 39, 69, 72, 98, 39, 15, 29, 69, 64, 92, 96, 49, 59, 62, 53, 82, 40, 37, 29, 41], "n": 23}}, {"idx": 4, "outputs": -2200, "inputs": {"a": [-88, -60, -60, -58, -56, -56, -46, -44, -40, -38, -32, -28, -22, -18, -12, -4, -2, 10, 24, 24, 28, 38, 42, 46, 54, 64, 72, 74, 78, 96, 96], "n": 26}}, {"idx": 5, "outputs": 0, "inputs": {"a": [0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1], "n": 39}}, {"idx": 6, "outputs": 27, "inputs": {"a": [1, 4, 6, 9, 10, 12, 17, 17, 18, 21, 22, 26, 26, 31, 32, 33, 34, 39, 42, 43, 45, 46, 48, 50, 53, 53, 54, 55, 60, 61, 62, 63, 63, 64, 70, 70, 70, 71, 71, 78, 86, 88, 91, 92, 95, 95, 96, 97, 99], "n": 28}}, {"idx": 7, "outputs": -1584, "inputs": {"a": [-42, 44, -80, -60, 48, 66, 54, -76, 26, -74, -10, 46, -50, 42, -26, -24, -14, 36, -2, -26, 16, -10, 20, -88, -78], "n": 19}}, {"idx": 8, "outputs": 0, "inputs": {"a": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], "n": 5}}, {"idx": 9, "outputs": 63, "inputs": {"a": [65, 32, 66, 82, 86, 98, 15, 33, 57, 3, 73, 45, 90, 82, 33, 99, 44, 76, 50, 89, 5, 7, 64], "n": 22}}]