401682: GYM100513 G FacePalm Accounting

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. FacePalm Accountingtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to participate in improving parks and garden squares. However, credible sources informed the FacePalm owner that the loss-making companies will not get such an offer. Moreover, the sources have also told how loss-making companies will be determined.

A company will be considered loss-making if for every k contiguous days the total income of the company is negative.

The FacePalm owner discussed the situation with his chief accountant, and they decided to change the report so that the company would look loss-making.

The company report for n days can be represented as a sequence of integers a1, a2, ..., an, where ai is the company income in the day i (negative values correspond to losses).

The accountant can change any values in this sequence, but no updated value can become less than the smallest value in the original report — otherwise the updated report will look absolutely implausible. Besides, the accountant wants the total change of the values to be as small as possible.

We will assume that the total change of the values is , where is the i-th value in the updated report.

Your task is to calculate the minimum required total change of the values and provide the updated report.

Input

The first line contains integers n and k (1 ≤ k ≤ n ≤ 2·105) — the number of days in the report and the number of days in the definition of loss-making company.

The second line contains n space-separated integers a1, a2, ..., an ( - 10000 ≤ ai ≤ 10000), where ai is the company income in day i.

It is guaranteed that at least one value of ai is negative.

Output

In the first line print the required minimum total change. In the second line print the corresponding updated report. No value in the updated report can be less than the minimum value of the original report.

If there are multiple solutions, print any of them.

ExamplesInput
5 4
3 -3 -1 1 2
Output
1
2 -3 -1 1 2
Input
8 3
2 1 -3 -2 4 -3 0 2
Output
3
1 1 -3 -2 2 -3 0 2
Input
4 2
-2 1 -2 1
Output
0
-2 1 -2 1
Input
3 3
-5 6 10
Output
12
-5 -5 9

加入题单

算法标签: