This page is still under construction.

Parts of this page are still being built. What you see may change.

Longest Even Contiguous Subsequence (Large)

Interview

Time limit1sMemory limit1024 MB

Summary
Given a sequence, delete at most K elements so that some remaining contiguous run consists only of even numbers, and report the longest such run.
Level

Medium5 of 10

Topics
Sliding window, Two pointers, Array, Greedy
Solved
No attempts yet

Problem

There is a sequence SS of length NN. Every element of SS is a positive integer.

You may delete an element at any position in SS, at most KK times in total.

For example, suppose SS is given as follows.

Sequence S : 1 2 3 4 5 6 7 8

If you delete the 4th element, 4, then SS becomes the following.

Sequence S : 1 2 3 5 6 7 8 

After deleting at most KK elements from SS, find the maximum length of a contiguous subsequence consisting only of even numbers.

Input

The first line contains the length NN of the sequence SS and the maximum number of deletions KK, separated by a space.

The second line contains the NN integers that make up the sequence SS, separated by spaces.

Output

Print the maximum length of a contiguous subsequence consisting only of even numbers after deleting at most KK elements from SS.

Constraints

  • 1≤N≤1,000,0001 \le N \le 1,000,000
  • 1≤K≤100,0001 \le K \le 100,000
  • 1≤1 \le element value ≤106\le 10^6

Examples1

  1. Example 1

    Input
    8 2
    1 2 3 4 5 6 7 8
    
    Expected output
    3