C++ | Greedy | Sorting | Easy | ~55% Time ~9% Space
\nclass Solution {\npublic: \n    int miceAndCheese(vector<int>& v1, vector<int>& v2, int k) {\n      int n = v1.size(), ans = 0;\n      vector<pair<int, int>> 
```\nclass Solution {\npublic: \n    int miceAndCheese(vector<int>& v1, vector<int>& v2, int k) {\n      int n = v1.size(), ans = 0;\n      vector<pair<int, int>> vp(n);\n      for(int i = 0; i < n; i++){\n        vp[i] = {v1[i] - v2[i], i};\n      }\n      sort(vp.begin(), vp.end(), greater<>());\n      for(int i = 0; i < n; i++){\n        int idx = vp[i].second;\n        if(i < k) ans += v1[idx];\n        else ans += v2[idx];\n      }\n      return ans;\n    }\n}\n```
['Greedy', 'C', 'C++']