#t419. 花店橱窗布置
花店橱窗布置
Flower Shop Window Arrangement
Problem Description
A flower shop has bouquets of flowers, each of a different variety. There are at least as many vases, arranged in a row in order. The positions of the vases are fixed, numbered from left to right as , where is the number of vases.
The bouquets can be moved, and each bouquet is identified by an integer . All bouquets must keep their identification order when placed into vases. For example, suppose the azalea has identification , the begonia , and the carnation ; then the azalea must be placed in a vase to the left of the begonia, and the begonia must be placed to the left of the carnation. Each vase can hold at most one bouquet.
The shape and color of each vase also differ, so placing different bouquets in different vases produces different aesthetic effects, represented by an aesthetic value (an integer ); the aesthetic value of an empty vase is . In the example above, the aesthetic values of different combinations of vases and bouquets can be represented by the following table:
| Vase 1 | Vase 2 | Vase 3 | Vase 4 | Vase 5 | |
|---|---|---|---|---|---|
| Azalea | |||||
| Begonia | |||||
| Carnation |
According to the table, an azalea placed in vase looks very nice, but placed in vase looks terrible.
To achieve the best aesthetic effect, the bouquets must be placed keeping their order, maximizing the total aesthetic value. If there is more than one arrangement achieving the maximum aesthetic value, output any one of them.
Input Format
The first line of the input file contains two integers and , the number of bouquets and the number of vases, respectively.
Next is the matrix , with rows, each containing integers; is the aesthetic value of placing bouquet in vase .
Output Format
The first line of the output file is an integer: the maximum aesthetic value. The next line contains integers: the vase number where each bouquet is placed.
Sample Input 1
3 5
7 23 -5 -24 16
5 21 -4 10 23
-21 5 -4 -20 20
Sample Output 1
53
2 4 5
Constraints
For of the data, .