Problem
A shop is open for n minutes. customers[i] people visit during minute i. grumpy[i] is 1 if the owner is grumpy that minute (those customers leave unhappy) and 0 if not (they leave happy). The owner knows a trick to stay calm for `minutes` consecutive minutes, usable only once. Return the maximum number of happy customers over the whole day.
Example 1
customers = [1, 0, 1, 2, 1, 1, 7, 5]
Example 2
- Input
- grumpy = [0, 1, 0, 1, 0, 1, 0, 1], minutes = 3
- Output
- 16
Using the trick on the last three minutes saves 1 + 5 = 6 extra customers on top of the 10 who are already happy.
Constraints
1 <= minutes <= customers.length == grumpy.length <= 2 * 10^40 <= customers[i] <= 1000grumpy[i] is either 0 or 1.