可见为2016noip提高组day2的第一题。
思想:二分答案,判断是否可行。
程序:
var
a,b:array[0..110000]of longint;i,l,r,ln,n,m,mid:longint;
function check(k:longint):boolean;
var
i,lst,ned:longint;
begin
lst:=0;ned:=0;
for i:=1 to n+1 do
if a[i]-a[lst]<k then ned:=ned+1 else lst:=i;
exit(ned<=m);
end;
procedure kp(l,r:longint);
var
i,j,x,t:longint;
begin
i:=l;j:=r;x:=a[(l+r)shr 1];
repeat
while a[i]<x do i:=i+1;
while a[j]>x do j:=j-1;
if i<=j then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
i:=i+1;j:=j-1;
end;
until i>j;
if i<r then kp(i,r);
if j>l then kp(l,j);
end;
begin
readln(ln,n,m);
for i:=1 to n do read(a[i]);a[n+1]:=ln;
kp(1,n);
l:=0;r:=ln;
while l<=r do
begin
mid:=(l+r)shr 1;
if check(mid) then l:=mid+1
else r:=mid-1;
end;
write(l);
end.