Logo
(追記) (追記ここまで)

21040번 - Maximum Subset 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB135796962.162%

문제

Let us define the value of a multiset of integers is the minimum difference between any two distinct elements. If a multiset contains two elements with the same value, then the two elements are considered different elements thus the value of the multiset is 0.

Given a multiset of integers A consisting of N elements, we want to find the value of the subset of A consisting of K elements which has the maximum value.

입력

The first line contains two integers: N K (2 ≤ KN ≤ 100,000) in a line denoting the number of elements of A and the number of elements of the subset of A we are looking for. The second line contains N integers: A1, A2, ..., AN (0 ≤ Ai ≤ 1,000,000,000) representing the elements of set A.

출력

The output contains the value of the subset of A consisting of K elements which has the maximum value, in a line.

제한

예제 입력 1

4 2
1 2 4 10

예제 출력 1

9

On the first sample, the optimal subset is {1, 10}. The value is 10 - 1 = 9.

예제 입력 2

4 3
1 2 4 10

예제 출력 2

3

On the second sample, the optimal subset is {1, 4, 10}. The value is 4 - 1 = 3.

예제 입력 3

4 4
1 2 4 10

예제 출력 3

1

On the third sample, the optimal subset is {1, 2, 4, 10}. The value is 2 - 1 = 1.

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2017 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /