Fast Food
The Fastfood chain Mcburger owns several restaurants a along. Recently, they have decided to build several depots-along, each one highway at a located and restaurent supplying Ral of the restaurants with the needed ingredients. Naturally, these depots should to placed so this average distance the between a restaurant and its assigned depot is Minim Ized. You are are to write a program that computes the optimal positions and assignments of the depots.
To make this more precise, the management of Mcburger has issued the following specification:you would be given the Positi ONS of n restaurants along highway as n integers $d _1 < D_2 < dots < d_n$ (These are the distances measured F Rom the company's headquarter, which happens to being at the same highway). Furthermore, a number $k (k le N) $ is given, the number of depots to is built.
The k depots is built at the locations of K different restaurants. Each restaurant is assigned to the closest depot and from which it would then receive its supplies. To minimize shipping costs, the total distance sum, defined as
Must be as small as possible.
Write a program that computes the positions of the K depots, such this total distance the sum is minimized.
Input
The input file contains several descriptions of fastfood chains. Each description starts with a line containing the two integers n and K. N and K'll satisfy $ le nle 200$, le k le 3 0$, $k le n$. Following this'll nlines containing one integer each, giving the positions di of the restaurants, ordered increasingly.
The input file would end with a case starting with n = k = 0. This case should is processed.
Output
For each chain, the number of the chain. Then output an optimal placement of the depots as follows:for each depot output a line containing its position and the RA Nge of Restaurants it serves. If there is more than one optimal solution, output any of them. After the depot descriptions output a line containing the total distance sum, as defined in the problem text.
Output a blank line after the test case.
Sample Input
6 3
5
6
12
19
20
27
0 0
Sample Output
Chain 1
Depot 1 at Restaurant 2 serves restaurants 1 to 3
Depot 2 at Restaurant 4 serves restaurants 4 to 5
Depot 3 at Restaurant 6 serves restaurant 6
Total Distance sum = 8