LeetCode:1029 两地调度

class Solution {
    public int twoCitySchedCost(int[][] costs) {
      
        int len = costs.length;
        int t = len/2;
        Arrays.sort(costs,(a,b)->{return a[0]-a[1]-(b[0]-b[1]);});
        int res=0;
        for(int i=0;i<t;i++){
            res+=costs[i][0];
        }
        for(int i=t;i<len;i++){
            res+=costs[i][1];
        }
        return res;
    }
}
原文地址:https://www.cnblogs.com/dloooooo/p/13808366.html