CF660C.Hard Process

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa with nn elements. Each element of aa is either 00 or 11 .

Let's denote the length of the longest subsegment of consecutive elements in aa , consisting of only numbers one, as f(a)f(a) . You can change no more than kk zeroes to ones to maximize f(a)f(a) .

输入格式

The first line contains two integers nn and kk ( 1<=n<=3105,0<=k<=n1<=n<=3·10^{5},0<=k<=n ) — the number of elements in aa and the parameter kk .

The second line contains nn integers aia_{i} ( 0<=ai<=10<=a_{i}<=1 ) — the elements of aa .

输出格式

On the first line print a non-negative integer zz — the maximal value of f(a)f(a) after no more than kk changes of zeroes to ones.

On the second line print nn integers aja_{j} — the elements of the array aa after the changes.

If there are multiple answers, you can print any one of them.

输入输出样例

  • 输入#1

    7 1
    1 0 0 1 1 0 1
    

    输出#1

    4
    1 0 0 1 1 1 1
    
  • 输入#2

    10 2
    1 0 0 1 0 1 0 1 0 1
    

    输出#2

    5
    1 0 0 1 1 1 1 1 0 1
    
首页