#1096
Unrated
RAZLIKA
시간 제한
0.5s
메모리 제한
64MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Goran Gašić

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 ≤ N ≤ 1 000 000) and K (1 ≤ K ≤ N - 2). The second line of input contains N space-separated positive integers – the sequence V (-5 000 000 ≤ Vi ≤ 5 000 000).

출력

The first and only line of output must contain the smallest possible sum M + m.

예제 입력 1

5 2
-3 -2 3 8 6

예제 출력 1

7

예제 입력 2

6 2
-5 8 10 1 13 -1

예제 출력 2

13

예제 입력 3

6 3
10 2 8 17 2 17

예제 출력 3

6
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.