<filename>Sec20_Greedy/q1029.py<gh_stars>1-10
#!/usr/bin/env python
# encoding: utf-8

class Solution:
    def twoCitySchedCost(self, costs: List[List[int]]) -> int:
        costs.sort(key = lambda x: x[0] - x[1])

        ans = 0
        n = len(costs) // 2
        for i in range(n):
            ans += costs[i][0] + costs[i+n][1]
        return ans


<filename>Sec20_Greedy/q1029.py<gh_stars>1-10
#!/usr/bin/env python
# encoding: utf-8

class Solution:
    def twoCitySchedCost(self, costs: List[List[int]]) -> int:
        costs.sort(key = lambda x: x[0] - x[1])

        ans = 0
        n = len(costs) // 2
        for i in range(n):
            ans += costs[i][0] + costs[i+n][1]
        return ans


#!/usr/bin/env python # encoding: utf-8