## IOI '00 P5 - Post Office

View as PDF

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 16M

Problem type
##### IOI '00 - Beijing, China

There is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer coordinate. There are no two villages in the same position. The distance between two positions is the absolute value of the difference of their integer coordinates.

Post offices will be built in some, but not necessarily all of the villages. A village and the post office in it have the same position. For building the post offices, their positions should be chosen so that the total sum of all distances between each village and its nearest post office is minimum.

You are to write a program which, given the positions of the villages and the number of post offices, computes the least possible sum of all distances between each village and its nearest post office, and the respective desired positions of the post offices.

#### Input Specification

The first line contains two integers: the number of villages and the number of post offices . The second line contains integers in increasing order. These integers are the positions of the villages. Each is between and , inclusive.

#### Output Specification

The first line should contain one integer : the sum of all distances between each village and its nearest post office as reported in the second line. The second line contains integers in increasing order. These integers are the locations of the distinct villages in which the post offices will be built. There may be several different solutions for the locations, and your program needs to output only one of them.

#### Sample Input

10 5
1 2 3 6 7 9 11 22 44 50

#### Sample Output

9
2 7 22 44 50

#### Scoring

If your program's output does not satisfy the output requirements, then your score is zero. Otherwise, your score will be computed based on Table as follows. If your program outputs sum and the actual least possible sum is , then calculate and find your score in the bottom row as a fraction of the maximum possible score on that test case.

 ~q = 1.0~ ~1.0 < q \le 1.1~ ~1.1 < q \le 1.15~ ~1.15 < q \le 1.2~ ~1.2 < q \le 1.25~ ~1.25 < q \le 1.3~ ~1.3 < q~ ~1~ ~0.5~ ~0.4~ ~0.3~ ~0.2~ ~0.1~ ~0~