C++ || Easy approach
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(nlogn)\n\n- Space complexity:O(n)\n\n# Code\n\nclass Solution {\npublic:\n    int mic
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:$$O(nlogn)$$\n\n- Space complexity:$$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int miceAndCheese(vector<int>& r1, vector<int>& r2, int k) {\n        int ans=0;\n        for(int i=0; i<r2.size(); i++){\n            ans+=r2[i];\n        }\n        vector<int>p;\n        for(int i=0; i<r1.size(); i++){\n            p.push_back(r1[i]-r2[i]);\n        }\n        \n        sort(p.begin(), p.end());\n        reverse(p.begin(), p.end());\n        for(int i=0; i<p.size(); i++){\n            if(k==0){\n                break;\n            }\n            ans+=p[i];\n            k--;\n            \n        }\n        return ans;\n    }\n};\n```
['Array', 'Sorting', 'C++']