PATROKLEIA WALLS
The ancient Greeks, since the Mycenaean period, they developed significant cities around the Argosaronic Gulf. Strategically located around the gulf (the cradle of ancient Greek civilization), important fortresses were constructed. At the eastern entrance of the gulf, where the mythic death of Aegeus, defined the Greek archipelago for over 3500 years, the ancient Greeks built an impregnable naval fortress. The "Patrokleia" walls protected the corresponding naval station for centuries. Patroclus (descendant of Theseus), with the help of the Atreides, used massive stone blocks to erect the fortification. According to myth, the god Apollo assisted in designing the walls.
Your task is to help your ancestors calculate which specific stone blocks they should use to secure Greek dominance in the Aegean for the next 3500 years. The final surface area of the walls should be as close as possible to the desired area. If this can be achieved in more than one way, it must be done using the smallest possible number of stone blocks.
Input Files:
The input files with the name patroclos.in are text files with the following structure: The first line contains two integers. The number Σ, 100 Σ 10.000 represents the desired surface area in square units for the walls, and the number N, 10 N 1.000 represents the number of stone blocks available. The next lines () contain the surface area of each stone block, expressed as an integer E, 1 E 900.
Output Files:
The output files with the name patroclos.out are text files with the following structure: The first line contains the integer K, 2 K 1.000, representing the number of stone blocks used. The next lines each contain an integer M, 1 M N, corresponding to the sequential number of the stone block used, in descending order of size.
Examples of Input - Output Files:
1ο
STDIN (patroclos.in)
100 10
40
22
11
20
7
8
6
2
3
4
STDOUT (patroclos.out)
5
1
2
4
3
5
2ο
STDIN (patroclos.in)
100 10
40
22
11
20
9
8
6
2
3
4
STDOUT (patroclos.out)
6
1
2
4
3
10
9
Comments