public class CountZeros {
public static void Count(int[] a, int n, int k) {
int zero = 0;
int l = 0;
int s=0,e=0;
int maxLen=0;
int[] arr=new int[n];
arr=a;
for ( int i = 0; i < n; i++) {
if (a[i] == 0) {
zero++;
}
while (zero > k) {
if (a[l] == 0) {
zero--;
}
l++;
}
if((i-l+1)>maxLen) {
maxLen=i-l+1;
s=l;
e=i;
}
}
System.out.println(maxLen);
for(int m=s;m<=e;m++){
a[m]=1;
}
for(int m=0;m<n;m++){
System.out.print(arr[m]+" ");
}
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
Count(a, n, k);
}
}
this is the code and is not passing all test cases