2335. Minimum Amount of Time to Fill Cups ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8class Solution { public: int fillCups(vector<int>& amount) { const int mx = ranges::max(amount); const int sum = accumulate(amount.begin(), amount.end(), 0); return max(mx, (sum + 1) / 2); } }; 1 2 3 4 5 6 7class Solution { public int fillCups(int[] amount) { final int mx = Arrays.stream(amount).max().getAsInt(); final int sum = Arrays.stream(amount).sum(); return Math.max(mx, (sum + 1) / 2); } } 1 2 3class Solution: def fillCups(self, amount: list[int]) -> int: return max(max(amount), (sum(amount) + 1) // 2)