Cheapest even split between two cities
A company flies 2n candidates to on-site interviews: exactly n of them go to city A and the other n to city B. costs[i] = [a, b] is the price of flying candidate i to A and to B. Return the lowest possible total price.
costs has an even length and may be empty; prices are non-negative integers. Aim for O(n log n).
Besides the tests, one large input (3,000 candidates) with a ~150 ms limit (scaled to your device's speed): brute force won't pass.
Examples
cheapest_split([[40,10],[15,60],[70,62],[20,25]])→107cheapest_split([[5,9],[3,1]])→6cheapest_split([[1,10],[2,20],[3,30],[4,40]])→37