记录编号 2053 评测结果 AAAAAAAAAA
题目名称 驾车旅行 最终得分 100
用户昵称 GravatarAchilles 是否通过 通过
代码语言 Pascal 运行时间 0.034 s
提交时间 2008-09-11 13:34:05 内存使用 0.11 MiB
显示代码纯文本
program tour;
var
  oil:array[0..100]of record
    len,money:real;
  end;
  lent,len,max,min:real;
  i,n:integer;
procedure move(station:integer;rest,cost:real);
begin
  if station=n+1 then begin
    if cost<min then min:=cost;
  end
  else begin
    if (oil[station+1].len-oil[station].len)/len<rest then begin
      if rest>(max/2)then move(station+1,(rest-(oil[station+1].len-oil[station].len)/len),cost)
      else begin
        move(station+1,rest-(oil[station+1].len-oil[station].len)/len,cost);
        move(station+1,max-(oil[station+1].len-oil[station].len)/len,cost+(max-rest)*oil[station].money+20);
      end;
    end
    else begin
      move(station+1,max-(oil[station+1].len-oil[station].len)/len,cost+(max-rest)*oil[station].money+20);
    end;
  end;
end;
begin
  assign(input,'tour.in');
  assign(output,'tour.out');
  reset(input);
  rewrite(output);
  readln(lent);
  readln(max,len,oil[0].money,n);
  oil[0].len:=0;
  for i:=1 to n do
    readln(oil[i].len,oil[i].money);
  min:=1.7e38;
  oil[n+1].len:=lent;
  oil[n+1].money:=0;
  move(0,max,oil[0].money);
  writeln(min:0:1);
  close(input);
  close(output);
end.