记录编号 2325 评测结果 AAAAAAAAAA
题目名称 驾车旅行 最终得分 100
用户昵称 GravatarE.M.B.E.R 是否通过 通过
代码语言 Pascal 运行时间 0.034 s
提交时间 2008-09-18 13:27:41 内存使用 0.11 MiB
显示代码纯文本
program EmberAsh;
var
tour,price:array[0..51]of real;
dis,v,km,p,ss,max,still,temp:real;
i,j,k,n,m:longint;

procedure try(o:integer);{at o-1 station now AND be going to o station}
var
i,j,k:longint;
t:real;
begin
if o=n+2 then
  begin
  if ss<max then
    max:=ss;
  end  {over}
    else
    begin
    if still*km>=tour[o]-tour[o-1] then
      begin
      if still>=v/2 then
        begin
        still:=still-(tour[o]-tour[o-1])/km;
        try(o+1);
        still:=still+(tour[o]-tour[o-1])/km;
        end;
      if still<v/2 then
        begin
        for k:=1 to 2 do
          begin
          if k=1 then
            begin
            still:=still-(tour[o]-tour[o-1])/km;
            try(o+1);
            still:=still+(tour[o]-tour[o-1])/km;
            end;
          if k=2 then
            begin
            ss:=ss+20+price[o-1]*(v-still);
            t:=still;
            still:=v;
            still:=still-(tour[o]-tour[o-1])/km;
            try(o+1);
            still:=still+(tour[o]-tour[o-1])/km;
            still:=t;
            ss:=ss-20-price[o-1]*(v-still);
            end;
        end;
      end;
      end; {enough to get next station}
      if still*km<tour[o]-tour[o-1] then
        begin
        ss:=ss+20+price[o-1]*(v-still);
        t:=still;
        still:=v;
        still:=still-(tour[o]-tour[o-1])/km;
        try(o+1);
        still:=still+(tour[o]-tour[o-1])/km;
        still:=t;
        ss:=ss-20-price[o-1]*(v-still);
        end;
    end;{else}
end;

BEGIN
assign(input,'tour.in');reset(input);
assign(output,'tour.out');rewrite(output);
readln(dis);
readln(v,km,p,n);
for i:=1 to n do
  readln(tour[i],price[i]);
tour[n+1]:=dis;
ss:=p;still:=v;
max:=maxlongint;
try(1);
writeln(max:0:1);
close(input);close(output);
END.