Fully Explained (O(1), O(1)), beats 100%
Intuition\nAt first, we sort the cups (we just need to find the biggest stack). If the biggest stack (0) is equal or bigger than the stacks left (1 and 2), it\'
# Intuition\nAt first, we sort the cups (we just need to find the biggest stack). If the biggest stack (0) is equal or bigger than the stacks left (1 and 2), it\'s pretty obvious that this will be the solution. If not, we simply have to pair cups from stacks 1 or 2 with cups from stack 0 till stack 0 has 0 cups, in such a way that we will be left with n and n or n+1 cups in stacks 1 and 2. This takes nums[2] + ceil((nums[0]+nums[1]-nums[2]+1)/2) steps, which is equal to ceil((nums[0]+nums[1]+nums[2]+1)/2).\n\n# Approach\nCase #1: nums[2] >= nums[0]+nums[1] :\nreturn nums[2];\nCase #2: nums[2] < nums[0]+nums[1] :\nreturn ceil((nums[0]+nums[1]+nums[2]+1)/2);\n\n# Complexity\n- Time complexity:\n# O(1)\n- Space complexity:\n# O(1)\n\n\n# Code\n```\nclass Solution {\npublic:\n    int fillCups(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        return (nums[2] >= nums[0]+nums[1] ? nums[2] : ceil((nums[0]+nums[1]+nums[2]+1)/2));\n    }\n};\n```\nIf this was helpful, drop a like. Happy coding!\n\n
['Math', 'C++']