比赛 |
NOIP_2 |
评测结果 |
AWWWWWWWTT |
题目名称 |
驾车旅行 |
最终得分 |
10 |
用户昵称 |
thegy |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-09-08 20:20:11 |
显示代码纯文本
program tour;
var
l,v,p,o,cost,ans:real;
i,n:longint;
a:array[0..5000,1..2]of real;
rout:array[1..5000]of 0..1;
fin,fout:text;
procedure find(s:real;x:longint);
var
dv,now,stay:real;
ii:longint;
begin
dv:=(a[x,1]-a[x-1,1])/p;
now:=s-dv;
if now<0 then exit;
if x=n+1 then
begin
writeln(cost:0:1);
for ii:=1 to n do
write(rout[ii],' ');
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:=round((cost+(v-now)*a[x,2])*10)/10;
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:=round((cost+(v-now)*a[x,2])*10)/10;
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;
cost:=o;
find(v,1);
writeln(fout,ans:0:1);
close(fin);
close(fout);
end.