Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool cmp (const vector <int> &v1 , const vector <int> &v2)
- {
- return (v1[0] - v1[1] < v2[0] - v2[1]);
- }
- int twoCitySchedCost(vector<vector<int>>& costs) {
- int res = 0;
- sort (costs.begin(), costs.end(), cmp);
- for (int i = 0 ; i < costs.size()/2 ; i++ )
- {
- res += costs[i][0] + (costs[costs.size()/2 + i][1]);
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement