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

15451번 - Computer Science 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB48171641.026%

문제

Vera has N integers a1, . . . , aN . A margin is a non-negative integer L such that it is possible to choose N integers x1, . . . , xN such that for all i, 1 ≤ i ≤ N, the interval [xi, xi + L] contains at least K of Vera’s integers and also contains ai.

Compute the minimum possible margin.

입력

Line 1 contains integers N and K (1 ≤ K ≤ N ≤ 2 × 105).

Line 2 contains N integers, a1, . . . , aN (−109 ≤ ai ≤ 109).

출력

Print one line with one integer, the minimum possible margin.

제한

예제 입력 1

5 3
1 -2 10 5 4

예제 출력 1

6

힌트

For the first example, one possible solution is to choose x1 = −1, x2 = −2, x3 = 4, x4 = 0, x5 = 0, which is illustrated below.

출처

Contest > Waterloo's local Programming Contests > 30 September, 2017 C번

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

출처

대학교 대회

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

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