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

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

&nbsp;
Example 1:

Input: amount = [1,4,2]
Output: 4
Explanation: 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.


Example 2:

Input: amount = [5,4,4]
Output: 7
Explanation: 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.


Example 3:

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


&nbsp;
Constraints:


	amount.length == 3
	0 &lt;= amount[i] &lt;= 100


class Solution:
    def fillCups(self, amount: List[int]) -> int:

        count = 0
        amount = sorted(amount, reverse=True)
        while amount[0] > 0:
            amount[0] -= 1
            amount[1] -= 1
            count += 1
            amount = sorted(amount, reverse=True)
        return count
class Solution {
    public int fillCups(int[] amount) {
         Arrays.sort(amount);
        int x=amount[0];
         int y=amount[1];
         int z=amount[2];
        int sum=x+y+z;
        if(x+y>z){return sum/2 +sum%2;}
        if(x==0&&y==0){return z;}
        else{return z;}
    }
}
class Solution {
public:
    int fillCups(vector<int>& amount) {
      sort(amount.begin(),amount.end());
      int x=amount[0];
      int y=amount[1];
      int z=amount[2];
      int sum=x+y+z;
      if(x+y>z) return sum/2+sum%2;
      if(x==0 && y==0) return z;
      else return z;
    }
};
var fillCups = function(amount) {
    var count = 0
    var a = amount
    while (eval(a.join("+")) > 0) {
        var max = Math.max(...a)
        a.splice(a.indexOf(max), 1)
        var max2 = Math.max(...a)
        a.splice(a.indexOf(max2), 1)
        count++
        if(max == 0) a.push(0)
        else a.push(max - 1)
        if (max2==0) a.push(0)
        else a.push(max2 - 1)
    } return count
}
Minimum Amount of Time to Fill Cups