Ctrl K

Three-Drink Dispenser

Easy
The office has a machine that serves three drinks: coffee, tea and cocoa. Every second it can pour either two cups of **different** drinks or a single cup of any drink. You are given an array orders of three numbers: orders[0] is the number of coffee cups ordered, orders[1] is tea and orders[2] is cocoa. Return the minimum number of seconds the machine needs to serve every order.
Example 1
orders=[3, 1, 2] → 3

There are 6 cups in total and at most two can be filled per second, so at least 3 seconds are needed. Three is enough: coffee+tea, coffee+cocoa, coffee+cocoa.

Example 2
orders=[1, 6, 2] → 6

Six cups of tea are needed and two cups of tea can never be poured in the same second, so it takes at least 6 seconds. The other 3 cups are poured alongside the tea.

Example 3
orders=[0, 0, 0] → 0
Constraints
  • len(orders) = 3
  • 0 ≤ orders[i] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsClearing the Stacks Evenly EasyStudios for Recording Sessions MediumGrowing Capital Project by Project HardJobs With a Cooldown MediumMost Orders by Their Deadlines Hard
loading Python…
Input
orders=[3, 1, 2]
Expected
3

Run checks the first 3 tests in your browser. Submit checks all 180 tests on the server, hidden ones included.