Problem B. Bricks in the wall

Author:A. Baranov   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

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.

Input format

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.

Output format

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.

Constraints

0 < Wi ≤ L ≤ 20, 0 < n ≤ 100

Sample tests

No. Standard input Standard output
1
8
1 2 5 1 4 1 3 1
5
4 7 1 6 2
2
7
1 2 5 5 2 3 3
6
5 6 0 3
3
6
1 1 1 1 1 1
7

0.078s 0.013s 13