spoj#ADAPLANT. Ada and Plants
Ada and Plants
Ada the Ladybug has grown many plants. She was trying to grow all plants with equal size. Now she is wondering about the biggest difference between heights of two plants which are near each other. Plants are near each other, if there are at most K plants between them.
Input
The first line contains T, the number of test-cases.The first line of each test-case will contain N, K, 1 < N ≤ 105 ,0 ≤ K ≤ 105 where N indicates number of plants.
Next line will contain N integers 0 ≤ hi ≤ 109 indicating height of i-th plant.
Sum of all N among all test-cases won't exceed 3*106
Output
For each test-case, print exactly one number - the biggest difference of plants near each other (biggest hi-hj such that |i-j|-1 ≤ K).Example Input
3 5 0 1 2 3 5 6 4 6 1 10 2 9 10 1 1 7 8 9 19 11 21 8 11 0
Example Output
2 9 13