#C2330. Furniture Placement

    ID: 45635 Type: Default 1000ms 256MiB

Furniture Placement

Furniture Placement

You are given a living room with n positions arranged in a line, and m pieces of furniture. Each furniture piece has a specified width. The task is to determine whether it is possible to place all the furniture pieces such that each piece is completely inside the living room and no two pieces overlap. In addition, at any position in the room the total width of the piece covering that position must not exceed L. Since placing furniture without overlap automatically ensures that the only piece covering a position has width at most L (provided each individual width does not exceed L), a necessary condition is that every piece’s width is ≤ L and the sum of all widths does not exceed n.

If a valid arrangement exists, output one possible configuration – the starting positions (1-indexed) of each furniture piece when placed consecutively from left to right. Otherwise, output -1.

inputFormat

The input is read from standard input. The first line contains three integers n, m, and L -- where n is the length of the living room, m is the number of furniture pieces, and L is the maximum allowed total width at any position. The second line contains m space‐separated integers, with the i-th integer representing the width of the i-th furniture piece.

outputFormat

If a valid arrangement exists, print the starting positions of the m furniture pieces as m space‐separated integers. Otherwise, print -1. The output should be written to standard output.

## sample
15 3 4
3 4 2
1 4 8

</p>