Ones with K Flips
You may flip at most K zeros to ones. Print the longest run of consecutive ones achievable.
Input: the first line has N and K; the second line has N values (0/1).
Output: the maximum achievable run of ones.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ K ≤ N
Sample Tests
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
Discussion (opens after you solve — no spoilers before)
No comments yet.