#1734. [Usaco2005 feb]Aggressive cows 愤怒的牛

[Usaco2005 feb]Aggressive cows 愤怒的牛

题目描述

Farmer John has built a new long barn, with n (2n105)n \ (2 \leq n \leq 10^5) stalls. The stalls are located along a straight line at positions x1,,xn (0xi109)x_1,\dots ,x_n \ (0 \leq x_i \leq 10^9). His c (2cn)c \ (2 \leq c \leq n) cows don't like this barn layout and become aggressive towards each other once put into a stall. To prevent the cows from hurting each other, FJ want to assign the cows to the stalls, such that the minimum distance between any two of them is as large as possible. What is the largest minimum distance?

农夫 John 建造了一座很长的畜栏,它包括 nn 个隔间,这些小隔间依次编号为 x1,,xnx_1,\dots ,x_n。但是,John 的 cc 头牛们并不喜欢这种布局,而且几头牛放在一个隔间里,他们就要发生争斗。为了不让牛互相伤害。John 决定自己给牛分配隔间,使任意两头牛之间的最小距离尽可能的大,那么,这个最大的最小距离是什么呢?

输入格式

  • Line 11: Two space-separated integers: nn and cc.

  • Lines 2n+12\dots n+1: Line i+1i+1 contains an integer stall location,xix_i.

  • 第一行:空格分隔的两个整数 nncc

  • 第二行至第 n+1n+1 行:i+1i+1 行指出了 xix_i 的位置。

输出格式

  • Line 11: One integer:the largest minimum distance.

  • 第一行:一个整数,最大的最小值。

5 3
1
2
8
4
9
3

样例说明

把牛放在 114488 这样最小距离是 33

数据规模与约定

对于 100%100\% 的数据,2n1052 \le n \le 10^50xi1090 \le x_i \le 10^92cn2 \le c \le n

题目来源

Gold