记录编号 332550 评测结果 AAAAAAAAAA
题目名称 跳高 最终得分 100
用户昵称 Gravatarzeppoe 是否通过 通过
代码语言 Pascal 运行时间 0.372 s
提交时间 2016-10-28 21:19:38 内存使用 1.18 MiB
显示代码纯文本
program wz;
var
a,b:array[0..100001]of int64;
m,n,ans,num,max,s:int64;
i,j:longint;


 procedure sort(x,y:longint);
 var
 i,j,mid,t:longint;
 begin
 i:=x;
 j:=y;
 mid:=b[(i+y) div 2];
 repeat
 while b[i]<mid do inc(i);
 while b[j]>mid do dec(j);
 if i<=j then
 begin
 t:=b[i];
 b[i]:=b[j];
 b[j]:=t;
 inc(i);
 dec(j);
 end;
 until i>j;
 if i<y then sort(i,y);
 if j>x then sort(x,j);
 end;

begin
assign(input,'jumpk.in');
assign(output,'jumpk.out');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do
begin
read(a[i]);
s:=s+i-1;
b[i]:=a[i]-s;
end;

sort(1,n);

num:=1;  max:=0;   ans:=0;

for i:=1 to n do
if b[i]=b[i+1] then inc(num) else
begin
if max<num then begin max:=num;ans:=b[i];end;
num:=1;
end;

for i:=1 to n do
b[i]:=ans+(i*(i-1) div 2);

writeln(n-max);
writeln(b[m]);
close(input);
close(output);
end.