✅ | C++ | Sorting And Compare
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int miceAndCheese(vector<int>& reward1, vector<int>& reward2, int k) {\n        vector<pair<int, int>> a;\n        for(int i = 0; i < reward1.size(); i++){\n            a.push_back({reward1[i] - reward2[i], i});\n        }\n    \n        sort(a.begin(), a.end(), greater<pair<int,int>>());\n        int sum = 0;\n        \n        for(int i = 0; i < k; i++){\n            sum += reward1[a[i].second];\n        }\n        \n        for(int i = k; i < a.size(); i++){\n            sum += reward2[a[i].second];\n        }\n        \n        return sum;\n    }\n};\n```
['C++']