Gửi bài giải
Điểm:
2,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given an array of N integers, select K elements out of these N elements in such a way that the minimum difference between each of the K numbers is the largest. Your task is to print out the largest minimum difference after choosing any K elements.
Input
The first line contains two integers N, K (1 ≤ N ≤ ~10^{5}~, 2 ≤ K ≤ N).
The second line contains N integers.
All integers dont exceed ~10^{9}~.
Output
- The largest minimum difference after choosing K elements from N elements.
Sample Input
4 3
2 6 2 5
Sample Output
1
Sample Input
7 4
1 4 9 0 2 13 3
Sample Output
4
Bình luận