记录编号 1894 评测结果 AAAAAAAAAA
题目名称 驾车旅行 最终得分 100
用户昵称 Gravatarthegy 是否通过 通过
代码语言 Pascal 运行时间 10.000 s
提交时间 2008-09-09 16:57:45 内存使用 0.00 MiB
显示代码纯文本
program tour;
var
  l,v,p,o,cost,ans:real;
  i,n:longint;
  a:array[0..100,1..2]of real;
  rout:array[1..100]of 0..1;
  fin,fout:text;
procedure find(s:real;x:longint);
var
  dv,now,stay:real;
  ii:longint;
begin
  if cost>ans then exit;
  dv:=(a[x,1]-a[x-1,1])/p;
  now:=s-dv;
  if now<0 then exit;
  if x=n+1 then
  begin
    if cost<ans then ans:=cost;
  end else begin
             if (now*p)<(a[x+1,1]-a[x,1]) then
             begin
               stay:=cost;
               cost:=cost+20;
               cost:=cost+(v-now)*a[x,2];
               rout[x]:=1;
               find(v,x+1);
               cost:=stay;
             end else begin
                        if now>=(v/2) then
                        begin
                          stay:=cost;
                          rout[x]:=0;
                          find(now,x+1);
                          cost:=stay;
                        end else begin
                                   stay:=cost;
                                   rout[x]:=0;
                                   find(now,x+1);
                                   cost:=stay;
                                   cost:=cost+20;
                                   cost:=cost+(v-now)*a[x,2];
                                   rout[x]:=1;
                                   find(v,x+1);
                                   cost:=stay;
                                 end;
                      end;
           end;
end;
begin
  assign(fin,'tour.in'); reset(fin);
  assign(fout,'tour.out'); rewrite(fout);
  read(fin,l,v,p,o,n);
  a[0,1]:=0;
  for i:=1 to n do
    read(fin,a[i,1],a[i,2]);
  a[n+1,1]:=l; a[n+1,2]:=0;
  cost:=o;
  ans:=10000000;
  find(v,1);
  writeln(fout,round(ans*10)/10:0:1);
  close(fin);
  close(fout);
end.