🔥Beats 90%🔥| Priority Queue | C++
\n\n\n# Complexity\n- Time complexity: O(N log(N))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n Add your space complexity here, e.g
\n\n\n# Complexity\n- Time complexity: O(N log(N))\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>&r1, vector<int>& r2, int k) {\n       priority_queue<int>pq;\n        long long ans=0;\n        for(int i=0;i<r1.size();i++){\n           pq.push(r1[i]-r2[i]);\n            ans+=r2[i];\n        }\n        while(k!=0){\n          ans+=pq.top();\n            pq.pop();\n            k--;\n        }\n        return ans;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']