leetcodedaybyday - Beats 100% with C++ and Beats 100% with Python3
IntuitionThe problem involves determining the minimum time required to fill cups with three types of liquid. At any second, we can reduce at most two cups simul
# Intuition
The problem involves determining the minimum time required to fill cups with three types of liquid. At any second, we can reduce at most two cups simultaneously. The goal is to minimize the total time required while ensuring all cups are filled.

To solve this, we focus on two key factors:
1. The cup with the maximum amount of liquid (`maxi`), as it represents the most time-consuming case if filled alone.
2. The total amount of liquid (`total`), as this gives the theoretical minimum time required if we could fill two cups at every second.

# Approach
1. **Calculate Total and Maximum**:
   - Traverse the `amount` array to calculate the total amount of liquid (`total`) and find the maximum value (`maxi`).

2. **Determine the Minimum Time**:
   - If we can always fill two cups simultaneously, the minimum time is `(total + 1) // 2`.
   - However, if the cup with the maximum amount requires more time than this, the answer is simply `maxi`.

3. **Return the Result**:
   - Return the maximum of `maxi` and `(total + 1) // 2`.

# Complexity
- **Time Complexity**:  
  \(O(1)\), as the array size is fixed at 3, and all operations are constant.

- **Space Complexity**:  
  \(O(1)\), as no additional space is used apart from a few variables.


---
# Code
```cpp []
class Solution {
public:
    int fillCups(vector<int>& amount) {
        int maxi = 0;
        int total = 0;
        for (int i = 0; i < amount.size(); i++){
            total += amount[i];
            maxi = max(maxi, amount[i]);
        }
        return max(maxi, (total + 1) / 2);
    }
};



```
```python3 []
class Solution:
    def fillCups(self, amount: List[int]) -> int:
        maxi = 0
        total = 0
        for i in range(len(amount)):
            total += amount[i]
            maxi = max(maxi, amount[i])
        return max(maxi, (total + 1) // 2)



```

['C++', 'Python3']