记录编号 |
332592 |
评测结果 |
AAAAAAAAAA |
题目名称 |
跳高 |
最终得分 |
100 |
用户昵称 |
desperado |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.469 s |
提交时间 |
2016-10-28 21:49:33 |
内存使用 |
30.68 MiB |
显示代码纯文本
var
a,b,c,d:array[1..1000000] of int64;
k,m,ans,total,n,max,p:int64;
i,j:longint;
procedure sort(l,r:longint);
var
i,j,x,y: longint;
begin
i:=l; j:=r; x:=c[(l+r) div 2];
repeat
while c[i] < x do i:= i+1;
while x<c[j] do j:= j-1;
if i<=j then
begin
y:=c[i]; c[i]:=c[j]; c[j]:=y;
i:=i+1; j:=j-1;
end;
until i > j;
if l < j then sort(l, j);
if i < r then sort(i, r);
end;
begin
assign(input,'jumpk.in');reset(input);
assign(output,'jumpk.out');rewrite(output);
readln(n,m);
max:=0;
b[1]:=1;
for i:=1 to n do begin read(a[i]);end;
for i:=2 to n do
begin
b[i]:=b[i-1]+i-1;
c[i]:=a[i]-b[i];
end;
for i:=1 to n do
begin
c[i]:=a[i]-b[i];
d[i]:=c[i];
// inc(d[c[i]]);
end;
sort(1,n);
c[n+1]:=maxlongint;
i:=0;
repeat
inc(i);
for j:=i+1 to n+1 do
if c[j]<>c[i] then break;
if p<j-i then begin p:=j-i;max:=c[i];end
else if (p=j-i) and (c[i]>max) then max:=c[i];
i:=j-1;
until i>=n;//p ci shu,max shu;
for i:=1 to n do
begin
if d[i]=max then begin k:=i;break;end;
end;
for i:=1 to k do
begin
a[i]:=a[k]-(k*(k-1)) div 2+(i*(i-1)) div 2
end;
for i:=k+1 to n do
begin
a[i]:=a[k]+(i*(i-1)) div 2-(k*(k-1)) div 2
end;
writeln(n-p);
writeln(a[m]);
close(input);
close(output);
end.