C++ (sorting) Vector only O(nlogn) solution
class Solution {\npublic:\n    int miceAndCheese(vector& reward1, vector& reward2, int k) {\n        \n         int ans = 0;\n        vector> vp;\n        \n   
class Solution {\npublic:\n    int miceAndCheese(vector<int>& reward1, vector<int>& reward2, int k) {\n        \n         int ans = 0;\n        vector<pair<int,int>> vp;\n        \n        int n = reward1.size();\n        \n        for(int i = 0;i<n;i++){\n            vp.emplace_back(reward1[i] - reward2[i], i);\n        }\n        \n        sort(vp.begin(),vp.end());\n        \n        while(k--){\n            pair<int,int> x =vp.back();\n            ans+=reward1[x.second];\n            vp.pop_back();\n        }\n        \n        \n        for(auto&i:vp){\n            ans+=reward2[i.second];\n        }\n        \n        \n        return ans;\n    }\n};
['Sorting']