|
|
back to boardMy Solution here,I've got AC,but not very fast program railway; const max=1000000000; maxn=10000; var p,dist:array[1..maxn]of longint; start,stop,n:integer; l:array[0..3]of longint; cost:array[1..3]of longint; procedure init; var i:integer; x:longint; begin for i:=1 to 3 do read(l[i]); for i:=1 to 3 do read(cost[i]); readln(n); readln(start,stop); if start>stop then begin x:=start; start:=stop; stop:=x; end; dist[1]:=0; for i:=2 to n do readln(dist[i]); end; function get(x,y:integer):longint; var i:integer; sum:longint; begin sum:=dist[y]-dist[x]; for i:=1 to 3 do if (sum>l[i-1]) and (sum<=l[i]) then begin get:=cost[i]; exit; end; end; procedure solve; var i,j:integer; temp:longint; begin for i:=start+1 to stop do p[i]:=Max; p[start]:=0; for i:=start+1 to stop do for j:=i-1 downto start do begin if dist[i]-dist[j]>l[3] then break; temp:=get(j,i); if p[j]+temp<p[i] then p[i]:=p[j]+temp; end; writeln(p[stop]); end; begin init; solve; end. So did I. Posted by use_c 9 Nov 2002 08:37 271903 03:35:23 9 Nov 2002 use_c 1031 C++ Accepted 1.331 sec 106K So did I..... Posted by aaakkk 11 Nov 2002 17:19 > 271903 03:35:23 > 9 Nov 2002 use_c 1031 C++ Accepted 1.331 sec 106K |
|
|