class Solution:

    def minCost(self, nums: List[int], cost: List[int]) -> int:

        line, half = sorted([[*x] for x in zip(nums, cost)]), sum(cost)//2

        for n, c in line:

            half -= c

            if half < 0 : return sum([abs(x - n) * y for x, y in line]) 


비슷한 문제로는 백준 8986번 전봇대가 있습니다.

해법은 1. 삼분 탐색과 2. 수학이 있는데 수학이 좀 더 코드가 짧아서 그걸로 올림