LogiQuest

420. Grumpy Bookstore Owner

MediumSliding Window

customers[i] people visit in minute i. When grumpy[i] = 1 those customers are unhappy. Once per day the owner can stay calm for x consecutive minutes. Print the maximum number of happy customers.

Input format

Line 1: n x Line 2: customers Line 3: grumpy (0/1)

Output format

The maximum happy customers.

Example 1

Input

8 3
1 0 1 2 1 1 7 5
0 1 0 1 0 1 0 1

Output

16

Example 2

Input

1 1
1
0

Output

1

Constraints

1 ≤ x ≤ n ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.

Loading the MyLoginn IDE…