Author: | A. Baranov | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
Let's consider a set of n two-dimensional bricks with arbitrary widths Wi and height 1.
It is required to build a wall of width L and maximum possible height (but no greater than 5) using minimum possible count of the bricks.
The bricks are arranged in layers, and each layer should be fully filled, meaning no gaps between bricks are allowed.
One is not allowed turn the bricks. They all should remain a horizontal position.
The input contains the number n, followed by exactly n integers Wi representing the widths of the bricks.
Next is the number L specifying the width of each layer.
The output should contain a sequence of brick numbers, arranged in the order of layer formation:
the bricks of the first layer, followed by those of the second layer, and so on.
It is assumed that the bricks are numbered starting from zero.
0 < Wi ≤ L ≤ 20, 0 < n ≤ 100
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|