比赛 20140321 评测结果 WWWAAAWWWW
题目名称 帮忙 最终得分 30
用户昵称 C语言入门 运行时间 0.216 s
代码语言 Pascal 内存使用 2.07 MiB
提交时间 2014-03-21 19:39:14
显示代码纯文本
var
 n,k,i,j:longint;
 max,tol:real;
 f:array [0..100001] of real;
 w,sum,z:array [0..100001] of longint;
begin
assign (input,'helpz.in');
assign (output,'helpz.out');
reset (input);
rewrite (output);
 read (n,k);
 for i:=1 to n do
 begin
  read (w[i]);
  sum[i]:=w[i]+sum[i-1];
 end;
 for i:=n downto 1 do
  if f[i+1]>w[i] then
   begin
    z[i]:=z[i+1];
    f[i+1]:=(sum[z[i]]-sum[i-1])/(z[i]-i+1);
   end
                 else
   begin
    z[i]:=i;
    f[i]:=w[i];
   end;
 for i:=1 to n-k+1 do
  begin
   if (sum[i+k-1]-sum[i-1])/k<f[i+k] then max:=(sum[z[i+k]]-sum[i-1])/(z[i+k]-i+1)
                                     else max:=(sum[i+k-1]-sum[i-1])/k;
   if max>tol then tol:=max;
  end;
 writeln(tol*1000:0:0);
close (input);
close (output);
end.