eolymp
bolt
Try our new interface for solving problems
Problems

Grouping

Grouping

You are given \textbf{N} integers \textbf{a = }\{\textbf{a_i}\}. Let \textbf{b = }\{\textbf{b_j}\} be such \textbf{K} numbers (not necessarily integers), that: \includegraphics{https://static.e-olymp.com/content/70/70bffd088084c0d659b0e246266001b096748db1.jpg} and \textbf{S} --- minimal. Find \textbf{S}. \InputFile First line contains two numbers \textbf{N} and \textbf{K}. Second line contains exactly \textbf{N} integers --- \{\textbf{a_i}\}. \OutputFile Only real number \textbf{S} with absolute or relative error not greater than \textbf{10^\{-8\}}. \textbf{Limits} \textbf{1} ≤ \textbf{N} ≤ \textbf{5000} \textbf{1} ≤ \textbf{K} ≤ \textbf{N} \textbf{0} ≤ \textbf{a_i} ≤ \textbf{400000}
Time limit 1 second
Memory limit 64 MiB
Input example #1
5 3
1 5 7 10 14
Output example #1
5.0

Example description: It makes sense to take {1, 7, 14} as {b_i}.