Greedy with priority queue
We can approach this greedily.\n\nAlways try to fill up 2 different cups, if we can\'t fill 2 different cups it means we have only 1 cup left to fill with X fil
We can approach this greedily.\n\nAlways try to fill up 2 different cups, if we can\'t fill 2 different cups it means we have only 1 cup left to fill with X fills.\n\nWe need to fill the cups that have the most capcity greedily, this will allow us to fill 2 cups for as long as possible.\n\nWhen we are left with 1 cup, just add the capacity to the result since we can only fill it 1 move at a time.\n\n# Code\n```\nfrom heapq import heapify, heappop, heappush\n\nclass Solution:\n    def fillCups(self, amount: List[int]) -> int:\n        moves = 0\n        max_heap = [-v for v in amount]\n        heapify(max_heap)\n        \n        while max_heap:\n            biggest = heappop(max_heap)\n            \n            if max_heap and max_heap[0] != 0:\n                moves += 1\n                second_biggest = heappop(max_heap)\n                \n                biggest += 1\n                second_biggest += 1\n                \n                if biggest != 0: heappush(max_heap, biggest)\n                if second_biggest != 0: heappush(max_heap, second_biggest)\n            \n            else:\n                moves += (-biggest)\n    \n        return moves\n    \n```
['Greedy', 'Python']