Company: Target
Difficulty: medium
Weighted Cost Minimization You are given two arrays, values and weights , each containing N positive integers. You must transform every element of values into a single common target number. Each transformation carries a cost: changing values[i] by one unit costs weights[i] per unit of change. Changing values[i] to target therefore costs |values[i] - target| * weights[i] . Your goal is to determine the target value that minimises the total cost of making all elements equal, where the total cost is total cost = |values[0] - target| * weights[0] + |values[1] - target| * weights[1] + ... + |values[N-1] - target| * weights[N-1] Print the minimum possible total cost. Input Format The first line contains a single integer N , the number of elements. The second line contains N space-separated integers representing the values array. The third line contains N space-separated integers representing the weights array. Output Format Print a single integer — the minimum total cost to equalise all elem