Angry cow / dairy attack [usaco]

Title Description

       Farmer John constructed a N (2 <= N <= 100,000) cow compartments, which compartments distributed in a straight line, coordinates x1, ..., xN (0 <= xi <= 1,000,000,000) .

       His C (2 <= C <= N) cow compartment dissatisfied position distribution, which is the cowshed there are other cattle and angry. In order to prevent fighting each other cows, Farmer John wants these cattle placed in designated compartments, all cattle in the adjacent two of the closest distance the better. So, how much of this recent maximum distance is it?

Input Format

    Line 1: two spaces separated by a number N and C.

    Of 2 ~ N + 1 lines: a line for each integer representing the coordinates of each compartment.

Output Format

    Output only one line, that is, two of the largest cattle nearest neighbor distance.

Sample input and output

Input # 1
5 3
1 
2 
8 
4 
9 
Output # 1
3

Guess you like

Origin www.cnblogs.com/zhugezisong/p/11343770.html