Nobita and Penny

0

0 votes
Medium
Problem

Nobita wants to buy the latest toy robot in the market but doesn't has enough money.
Nobita has n coins with value either 1 or 5.
Doraemon gave him a new gadget with which he can convert 1 valued coins to 5.
Doraemon is affraid that Nobita might misuse his gadget so he decides to play a little game with Nobita.
He placed all the coins in a line randomly. Let's denote the length of the longest subsegment of consecutive 5 coins in this line as L.
Nobita can keep only the coins in this subsegment while Doraemon will buy doracakes from the rest of the coins.
Nobita can use the gadget not more than k times to maximise L.
Help Nobita extract maximum coins of value 5 from the game.

Input:-

First line contains number of test cases T.
First line of each test case contains two integers n and k.
Second line of each test contains n space-separated integers a[1], a[2],..., a[i],..., a[n] denoting the line formed from n coins.

Output:-

For each test case print two lines:-
In first line print the difference between the total value of coins after and before the game Nobita has.
In second line print n integers b[1], b[2],..., b[i],..., b[n] denoting the line formed with n coins after using the gadget not more than k times.
If there are multiple answers print the line formed with earliest possible use of the gadget.

Constraints:-

1 ≤ T ≤ 100
1 ≤ n105
0 ≤ k ≤ n
a[i] = 1 or 5

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Initially Nobita has 25 coins and Doraemon has 0 coin.
After the game Nobita has 35 coins and Doraemon has 2 coins.

Editor Image

?