比赛 NOIP_2 评测结果 AWWAAAWWWW
题目名称 驾车旅行 最终得分 40
用户昵称 lc 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-09-08 22:09:37
显示代码纯文本
program day2_2;
 var
     dis:array[0..50] of real;
     mon:array[1..50] of real;
     distotal,V,S,money:real;
     n:integer;
 procedure init;
 var
     i:integer;

 begin
  assign(input,'tour.in');
  assign(output,'tour.out');
  reset(input); rewrite(output);
  read(distotal);
  read(V,S,money,n);
  for i:=1 to n do
   read(dis[i],mon[i]);
  inc(n);
  dis[n]:=distotal;
  mon[n]:=0;
  end;

 procedure main;
  var
    min,LV:real;
    T,minpos,k:integer;

 begin
  T:=0; LV:=V;
  while T<>n do begin
   min:=maxlongint;
   for k:=1 to n-T do
   if dis[T+k]-dis[T]<=LV*S
   then if mon[T+k]<min
   then
       begin
       min:=mon[T+k];
       minpos:=k
       end;
   if min=maxlongint
   then
       begin
       money:=money+mon[T]*(V-LV)+20;
       LV:=V
       end
   else
       begin
       LV:=LV-(dis[T+minpos]-dis[T])/S;
       T:=T+minpos
       end;
   end;
 end;

 begin
  init;
  main;
  writeln(money:0:1);
  close(input); close(output);
 end.