📄 tour.pas
字号:
program E1_9; {tour}
var distance,capacity,km:real;
ic,minc:longint;
n:byte;
station:array[0..50,1..2] of real;
procedure init;
var i:byte; c:real;
begin
assign(input,'tour.in');
reset(input);
readln(input,distance);
readln(input,capacity,km,c,n);
ic:=round(c*100);
for i:=1 to n do
begin
readln(input,station[i,1],station[i,2]);
station[i,2]:=station[i,2]*100;
end;
close(input);
end;
procedure search;
procedure drive(stop:byte;cost:longint);
var num:byte;
begin
if station[stop,1]+capacity*km>=distance then
begin
if cost<minc then minc:=cost;
exit;
end;
num:=stop+1;
while (num<n) and (station[num+1,1]<=station[stop,1]+capacity*km) and (station[num,1]<=station[stop,1]+capacity*km/2) do
inc(num);
if(num=n) or (station[num+1,1]>station[stop,1]+capacity*km) then
drive(num,cost+2000+round((station[num,1]-station[stop,1])/km*station[num,2]));
while (num<=n) and (station[num,1]<=station[stop,1]+capacity*km/2) do
inc(num);
while (num<=n) and (station[num,1]<=station[stop,1]+capacity*km) do
begin
drive(num,cost+2000+round((station[num,1]-station[stop,1])/km*station[num,2]));
inc(num);
end;
end;
begin {search}
minc:=maxlongint;
drive(0,ic);
end;
procedure print;
begin
assign(output,'tour.out');
rewrite(output);
writeln(output,minc/100:0:1);
close(output);
end;
begin
init;
search;
print;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -