Leetcode Note: Go - Minimum Amount of Time to Fill Cups
Minimum Amount of Time to Fill Cups - LeetCode
https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/
- Go 言語で取り組んだメモ
回答
Minimum Amount of Time to Fill Cups - LeetCode
https://leetcode.com/problems/minimum-amount-of-time-to-fill-cups/solutions/2634293/golang-solution-based-on-sorting/
func fillCups(amount []int) int {
sort.Ints(amount)
a, b := amount[0] + amount[1], amount[2]
if a < b {
return b
}
return b + (a - b + 1) / 2
}