Python max heap O(nlogn)
\nclass Solution:\n    def miceAndCheese(self, reward1: List[int], reward2: List[int], k: int) -> int:\n        \n        #build max heap, based on the extra we
```\nclass Solution:\n    def miceAndCheese(self, reward1: List[int], reward2: List[int], k: int) -> int:\n        \n        #build max heap, based on the extra we can get if we \n        #choose reward1\n        heap = []\n        for i in range(0,len(reward1)):\n            heap.append( [ -reward1[i]+reward2[i] ,i  ])\n        heapq.heapify(heap)\n\n        #eat the ones where we get the most extra and store those\n        #mark those visited\n        visited ,res = {},0\n        while(k):\n            idx = heapq.heappop(heap)[1]\n            res += reward1[idx]\n            visited[idx] = 1\n            k-=1\n\n        # eat the remaining from the reward2 \n        for i in range(0,len(reward2)):\n            if(visited.get(i) != None ):\n                continue\n            res += reward2[i]\n        return res \n```
['Python3']