~/algor $ cat problems/ikki-korsatkich-nollarni-almashtirish
Replace at most k zeros
Medium
1000 ms
128 MB
56%
An array of $n$ elements consisting of $0$s and $1$s and an integer $k$ are given. At most $k$ zeros of the array may be replaced by ones. After that, what is the largest possible length of a segment of consecutive elements consisting only of ones?
Input
The first line contains two integers: $n$ and $k$.
The second line contains $n$ numbers ($0$ or $1$).
Output
One integer — the largest length.
Note
$1 \le n \le 2 \cdot 10^{5}$
$0 \le k \le n$
Examples
Input #1
11 2 1 1 1 0 0 0 1 1 1 1 0
Output #1
6
Input #2
3 0 0 0 0
Output #2
0