A "miss" time is the absolute value of the difference between the time of an alignment point and the nearest time of the beginning or end of a programme. The "total miss time" at a particular level of importance is the sum of all the miss times for alignment points at that level of importance. One programme order is better than another if it has a lower total miss time at some level of importance and the same total miss time at all higher levels of importance (if any).
The next line of input specifies the alignment points. The total number of such points, a (0<= a <=8), appears first followed by a pairs of integers. The first integer in each pair, i (1<= i <=5), gives the importance of the alignment point. Alignment points marked 1 are most important; those marked 2 are of secondary importance, etc. The second integer in each pair, t, specifies the time when the alignment point occurs. No two alignment points in the same data set will have the same value of t.
Data set n
where n is the number of the data set (1 for the first data
set, 2 for the second, etc.). On the following line, your solution
should output the lengths of the programmes in the order in which they
should be shown to achieve the best synchronization with the alignment
points. On the third line, output the total number of minutes by which
the alignment points were missed (the sum of all total miss times).
There may be more than one best programme order for an input data
set. Any one of these best orders is acceptable.
4 30 45 45 15 3 1 60 2 90 3 15 6 10 15 13 18 25 33 4 1 30 2 15 2 45 1 60 0
Data set 1 Order: 15 45 30 45 Error: 0 Data set 2 Order: 15 13 33 25 18 10 Error: 19