Razlika
의견: 0
\(4^{th}\) round, January \(19^{th}\), 2013
Mirko's newest math homework assignment is a very difficult one! Given a sequence, V, of N integers,
remove exactly K of them from the sequence. Let M be the largest difference of any two remaining
numbers in the sequence, and m the smallest such difference. Select the K integers to be removed from
V in such a way that the sum \(M + m\) is the smallest possible. Mirko isn't very good at math, so he has
asked you to help him!
The first line of input contains two positive integers, N (\(3 \le N \le 1\,000\,000\)) and K (\(1 \le K \le N - 2\)).
The second line of input contains N spa\(ce-se\)parated positive integers – the sequence V (-5 000 000 ≤
\(V_{i} \le 5\,000\,000\)).
The first and only line of output must contain the smallest possible sum \(M + m\).
5 2
-3 -2 3 8 676 2
-5 8 10 1 13 -1136 3
10 2 8 17 2 176평가 및 의견
Razlika
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Razlika