Sorting [C++] Solution
\n\n# Code\n\nclass Solution {\npublic:\n    int miceAndCheese(vector<int>& a, vector<int>& b, int k) {\n        vector<pair<int,int>> v;\n        int n = a.siz
\n\n# Code\n```\nclass Solution {\npublic:\n    int miceAndCheese(vector<int>& a, vector<int>& b, int k) {\n        vector<pair<int,int>> v;\n        int n = a.size();\n        \n        for(int i=0;i<n;i++)\n            v.push_back({a[i]-b[i],i});\n        \n        sort(v.begin(),v.end());\n        \n        int ans = 0, i = n-1;\n        while(k){\n            ans+= a[v[i].second];\n            i--;\n            k--;\n        }\n        while(i>=0){\n            ans+= b[v[i].second];\n            i--;\n        }\n        return ans;\n    }\n};\n```
['Sorting', 'C++']