Easy and simple C++ code ✔
\n# Complexity\n- Time complexity:  O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n)
\n# Complexity\n- Time complexity:  O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int miceAndCheese(vector<int>& a, vector<int>& b, int k) {\n        int ans=0,n=a.size();\n        //ans indicates all rewards achieve by Mice 2\n        for (int i = 0; i < n; ++i) {\n           ans=ans+b[i];\n        }\n        vector<int>d;\n        // and make the difference vector between 2 mice rewards\n         for(int i=0;i<n;i++){\n          d.push_back(a[i]-b[i]);\n        }\n        //Sort them in descending order because difference between them is maximize\n        sort(d.begin(),d.end(),greater<int>());\n        int i=0;\n        //now add k rewards achieved by mice 1 \n        // and subtract those ith reward from mice 2\n        while(k--){\n          // d[i] indicates difference between a[i] and b[i]\n          // add them in ans because ans subtracts b[i] and add a[i] in it that\'s why we add directly d[i] = a[i] - b[i] . \n          ans=ans+d[i];\n          i++;\n        }\n        return ans;\n        \n        \n    }\n};\n\n```
['C++']