Background
For hundreds of years fire departments all over the world have been using water for their fight against the fire. Unfortunately, one cannot always find enough water right where the fire is burning. Accordingly, the fire departments are equipped with lots of pumps and pipes to transport the water to where it is needed.Setting up the system of pumps and pipes might not be such an easy task, as there are several restrictions one has to take care of.
flow (f) in liters per minute loss of pressure in millibar per meter
200 1
400 3
600 6
800 10
1000 15
1200 20
The first line contains the number of scenarios.
For each scenario, you are first given an integer f ∈ {200, 400, 600, 800, 1000, 1200} on a line by itself,indicating the desired flow in liters per minute. The next line contains two integers n and m, separated by a single blank, where 1 <= n <= 20 is the number of pipes to be used, and 1 <= m <= 400 is the number of segments with a constant slope.
The followingmlines describe thesemsegments, each containing integers l and s, separated by a single blank, where l > 0 is the length in meters and s is the slope measured in per cent (s = 10 means that pipes of a length of 100 meters ascend by 10 meters, s = -50 means they descend 50 meters; -100 <= s <= 100).
It is guaranteed that the m given lengths add up to n times 20 meters.
The output for each scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. The next line contains the number of pumps in the optimal solution (if it exists),followed by a colon ":" and a single blank, and the positions of the pumps separated by commas "," and no blanks. If no placement of the pumps satisfies the given criteria, print a line containing "no solution" instead. Finish the output of each scenario with an additional blank line.
2 600 7 3 70 50 30 -25 40 25 1000 8 4 20 0 80 -100 20 10 40 30
Scenario #1: 2: 0,2 Scenario #2: no solution