#C3527. Minimum Maximum Price Difference
Minimum Maximum Price Difference
Minimum Maximum Price Difference
You are given n books along with their prices. Your task is to select a contiguous group of k books such that the difference between the highest and lowest prices in that group is minimized. Although an extra parameter m is provided (indicating the number of categories), it is not used in the computation.
More formally, let (prices) be the list of the book prices. First, sort (prices) in non-decreasing order. Then, for every contiguous subarray of length (k), compute the difference between its maximum and minimum values. Output the smallest difference among all possible subarrays of length (k).
inputFormat
Input is read from standard input (stdin).
The first line contains three space-separated integers (n), (m), and (k), where (n) is the total number of books, (m) is a parameter (not used in the computation) and (k) is the number of books to select.
The second line contains (n) space-separated integers representing the prices of the books.
outputFormat
Output the minimum possible maximum price difference (i.e. the smallest difference between the maximum and minimum price in a contiguous subarray of length (k)) to standard output (stdout).## sample
5 1 3
7 5 9 1 3
4
</p>