记录编号 1914 评测结果 AAAAAAAAAA
题目名称 驾车旅行 最终得分 100
用户昵称 Gravatarelysian 是否通过 通过
代码语言 Pascal 运行时间 0.003 s
提交时间 2008-09-10 13:39:00 内存使用 0.00 MiB
显示代码纯文本
program gracia;
const
fin='a.txt';fout='b.txt';
var
dis:array[0..52] of double;
pay:array[0..52] of double;
L,min,full,cost,disall,perdis:double;
n:longint;
f1,f2:text;

procedure init;
var
i:longint;
begin
assign(f1,'tour.in');reset(f1);
readln(f1,disall);
readln(f1,L,perdis,cost,n);
for i:=1 to n do
readln(f1,dis[i],pay[i]);
close(f1);
dis[n+1]:=disall;
full:=L*perdis;
end;

procedure search(i:longint;total,k:double);
var
tmp:double;
begin
if i>=n+1 then
begin
if total<min then min:=total;
exit;
end;

k:=k-(dis[i]-dis[i-1]);
tmp:=(full-k)/perdis*pay[i]*10+200;

if k<(dis[i+1]-dis[i]) then search(i+1,total+tmp,full)
else if k>full/2 then search(i+1,total,k)
else begin
       search(i+1,total+tmp,full);
       search(i+1,total,k);
       end;
end;

BEGIN
init;
min:=maxlongint;
search(1,0,full);
min:=min+cost*10;
assign(f2,'tour.out');rewrite(f2);
writeln(f2,min/10:0:1);
close(f2);
END.