Washer
题号:NC221646
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You have n clothes and a washer. The washer is large enough to wash all clothes at once. However, we should worry about the color transfer: if we put clothes of different colors in the washer, the dye from one may stain another. Precisely, let r i , g i , bi denote the amount of red, green, blue color of the i-th clothes. When n clothes are washed together, the color transfer c is defined by

ܿ (r i - r + (g i - g + (b i - b

where r, g, and b are the averages of r_i, g_i, and b_i, respectively. The i-th clothes with r_i, g_i, and b_i is defined as a point (r_i, g_i, b_i) in 3-dimensional RGB space. You can assume that no three points (clothes) are on a same line and no four points (clothes) are on a same plane in RGB space.

The washer consumes a lot of electricity, and you have to partition n clothes into at most k groups, and run the washer for each group. The total color transfer is the sum of color transfers from each run. Given the color information of n clothes and k, write a program to calculate the minimum total color transfer.

输入描述:

Your program is to read from standard input. The first line contains two integers n (1 ≤ n ≤ 100) and k (1 ≤ k ≤ 2). In the following n lines, the i-th line contains three integers r_i, g_i, b_i 

输出描述:

Your program is to write to standard output. Print exactly one line containing the minimum total color transfer, rounded to the sixth decimal point.
示例1

输入

复制
2 1
36 16 85
74 87 38

输出

复制
4347.000000
示例2

输入

复制
1 2
12 26 90

输出

复制
0.000000
示例3

输入

复制
3 2
93 50 26
40 0 77
99 10 29

输出

复制
822.500000