Tap here to switch tabs
Problem
Submissions

Problem: Grumpy Bookstore Owner

med
30 min
Try to solve the Grumpy Bookstore Owner problem.

Statement

You are given two integer arrays customers and grumpy, each of length n, and an integer minutes. For each index i, customers[i] is the number of customers that enter the bookstore during minute i. If grumpy[i] equals 11, the owner is grumpy during minute i and all customers in that minute are unsatisfied. If grumpy[i] equals 00, the owner is not grumpy and all customers in that minute are satisfied.

The owner can use a secret technique exactly once to avoid being grumpy for a consecutive window of minutes minutes. During that chosen window, customers are satisfied regardless of the values in grumpy.

Return the maximum total number of satisfied customers that can be achieved.

Constraints:

  • n == customers.length == grumpy.length

  • 1≤1 \leq minutes ≤\leq n ≤2⋅104\leq 2 \cdot 10^4

  • 0≤0 \leq customers[i] ≤1000\leq 1000

  • grumpy[i] is either 00 or 11

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Grumpy Bookstore Owner

med
30 min
Try to solve the Grumpy Bookstore Owner problem.

Statement

You are given two integer arrays customers and grumpy, each of length n, and an integer minutes. For each index i, customers[i] is the number of customers that enter the bookstore during minute i. If grumpy[i] equals 11, the owner is grumpy during minute i and all customers in that minute are unsatisfied. If grumpy[i] equals 00, the owner is not grumpy and all customers in that minute are satisfied.

The owner can use a secret technique exactly once to avoid being grumpy for a consecutive window of minutes minutes. During that chosen window, customers are satisfied regardless of the values in grumpy.

Return the maximum total number of satisfied customers that can be achieved.

Constraints:

  • n == customers.length == grumpy.length

  • 1≤1 \leq minutes ≤\leq n ≤2⋅104\leq 2 \cdot 10^4

  • 0≤0 \leq customers[i] ≤1000\leq 1000

  • grumpy[i] is either 00 or 11