<p>You have a water dispenser that can dispense cold, warm, and hot water. Every second, you can either fill up <code>2</code> cups with <strong>different</strong> types of water, or <code>1</code> cup of any type of water.</p>

<p>You are given a <strong>0-indexed</strong> integer array <code>amount</code> of length <code>3</code> where <code>amount[0]</code>, <code>amount[1]</code>, and <code>amount[2]</code> denote the number of cold, warm, and hot water cups you need to fill respectively. Return <em>the <strong>minimum</strong> number of seconds needed to fill up all the cups</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> amount = [1,4,2]
<strong>Output:</strong> 4
<strong>Explanation:</strong> One way to fill up the cups is:
Second 1: Fill up a cold cup and a warm cup.
Second 2: Fill up a warm cup and a hot cup.
Second 3: Fill up a warm cup and a hot cup.
Second 4: Fill up a warm cup.
It can be proven that 4 is the minimum number of seconds needed.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> amount = [5,4,4]
<strong>Output:</strong> 7
<strong>Explanation:</strong> One way to fill up the cups is:
Second 1: Fill up a cold cup, and a hot cup.
Second 2: Fill up a cold cup, and a warm cup.
Second 3: Fill up a cold cup, and a warm cup.
Second 4: Fill up a warm cup, and a hot cup.
Second 5: Fill up a cold cup, and a hot cup.
Second 6: Fill up a cold cup, and a warm cup.
Second 7: Fill up a hot cup.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> amount = [5,0,0]
<strong>Output:</strong> 5
<strong>Explanation:</strong> Every second, we fill up a cold cup.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>amount.length == 3</code></li>
	<li><code>0 &lt;= amount[i] &lt;= 100</code></li>
</ul>

import heapq
class Solution:
    def fillCups(self, amount: List[int]) -> int:
        amount = [i * -1 for i in amount if i > 0]
        if len(amount) == 0:
            return 0

        heapq.heapify(amount)
        c = 0

        while True:
            if len(amount) < 1:
                return c
            elif len(amount) <=1:    
                c = c + (amount[0]* -1)
                return c
                
            x1 = (heapq.heappop(amount) * -1) - 1
            x2 = (heapq.heappop(amount) * -1) - 1
            if x1 != 0:
                heapq.heappush(amount,(x1 )* -1)
            if x2 != 0:
                heapq.heappush(amount,(x2 )* -1)
            c = c + 1


        # count = 0
        # largest = 0
        # mini = min(amount)
        # for num in amount:
        #     if num > largest:
        #         second_largest = largest
        #         largest = num
        #     elif num > second_largest and num != largest:
        #         second_largest = num

        # count =  second_largest
        # print(count)
        # amount.remove(second_largest)    
        # amount.remove(largest)  
        # amount.append(largest-second_largest)
        # print(amount)
        # count = count + max(amount)
        # print(count)
        # return 4
        return max(max(amount), ceil(sum(amount)/2))
31