Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Make Array Equal

Try to solve the Minimum Cost to Make Array Equal problem.

Statement

You are given two 00 indexed integer arrays nums and cost, both of length n.

In one operation, you can increase or decrease any element nums[i] by 11. The cost of performing this operation on nums[i] is cost[i].

Return the minimum total cost to make all elements in nums equal.

Constraints:

  • n ==== nums.length ==== cost.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums[i], cost[i] ≤106\leq 10^6

  • The test cases are generated such that the minimum cost does not exceed 253−12^{53} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Make Array Equal

Try to solve the Minimum Cost to Make Array Equal problem.

Statement

You are given two 00 indexed integer arrays nums and cost, both of length n.

In one operation, you can increase or decrease any element nums[i] by 11. The cost of performing this operation on nums[i] is cost[i].

Return the minimum total cost to make all elements in nums equal.

Constraints:

  • n ==== nums.length ==== cost.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums[i], cost[i] ≤106\leq 10^6

  • The test cases are generated such that the minimum cost does not exceed 253−12^{53} - 1