P27441 [AtCoder] Paid Vacation
提高-
题目描述

Problem Description

joisino's big sister loves long holidays.
Currently, the schedule for the next $ N $ days is determined, indicating whether each day is a holiday or not.
Additionally, joisino's big sister can take up to $ K $ paid vacations during this period.
In other words, she can change up to $ K $ non-holiday days to holiday days.
joisino's big sister wants to know the maximum number of consecutive holiday days that can be achieved and decided to write a program to find this out.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ H_1 $ $ H_2 $ .. $ H_N $

  • The first line contains the number of days $ N(1≦N≦10^5) $ for which the schedule is determined and the number of paid vacations $ K(1≦K≦10^5) $.
  • The second line contains $ N $ numbers, each either $ 1 $ or $ 0 $, separated by spaces. The $ i $-th number indicates whether the $ i $-th day is a holiday ($ 1 $) or not ($ 0 $).

Output Format

Output the maximum number of consecutive holiday days that can be achieved in one line.

Sample Input and Output

Sample Input #1

6 2
1 0 1 0 0 1

Sample Output #1

4

Sample Input #2

10 1
1 1 0 0 1 1 1 0 1 1

Sample Output #2

6

Notes/Hints

Sample Explanation 1

Taking paid vacations on the 2nd and 4th days will achieve the maximum consecutive holiday days.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
6 2 1 0 1 0 0 1
样例输出
4