304629: CF883I. Photo Processing
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Photo Processing
题意翻译
给出n个数,让你分组,每组最少m个 规定每组的价值是组里面最大数-最小数 要求使得最大价值最小 n,m<=3*10^5题目描述
Evlampiy has found one more cool application to process photos. However the application has certain limitations. Each photo $ i $ has a contrast $ v_{i} $ . In order for the processing to be truly of high quality, the application must receive at least $ k $ photos with contrasts which differ as little as possible. Evlampiy already knows the contrast $ v_{i} $ for each of his $ n $ photos. Now he wants to split the photos into groups, so that each group contains at least $ k $ photos. As a result, each photo must belong to exactly one group. He considers a processing time of the $ j $ -th group to be the difference between the maximum and minimum values of $ v_{i} $ in the group. Because of multithreading the processing time of a division into groups is the maximum processing time among all groups. Split $ n $ photos into groups in a such way that the processing time of the division is the minimum possible, i.e. that the the maximum processing time over all groups as least as possible.输入输出格式
输入格式
The first line contains two integers $ n $ and $ k $ ( $ 1<=k<=n<=3·10^{5} $ ) — number of photos and minimum size of a group. The second line contains $ n $ integers $ v_{1},v_{2},...,v_{n} $ ( $ 1<=v_{i}<=10^{9} $ ), where $ v_{i} $ is the contrast of the $ i $ -th photo.
输出格式
Print the minimal processing time of the division into groups.
输入输出样例
输入样例 #1
5 2
50 110 130 40 120
输出样例 #1
20
输入样例 #2
4 1
2 3 4 1
输出样例 #2
0