|
|
back to boardwhere is the error? I don't think there is any error, but I get a "wrong answer". var cost: array[1..10000] of longint; len: array[1..10000] of longint; l1,l2,l3,c1,c2,c3: longint; i,j,start,over,n: integer; begin readln(l1,l2,l3,c1,c2,c3); readln(n); readln(start,over); for i:=2 to n do readln(len[i]); for i:=2 to n do cost[i]:=1000000000; len[1]:=0; cost[start]:=0; for i:=start to over-1 do begin j:=i+1; while (len[j]-len[i]<=l3) and (j<=over) do begin if len[j]-len[i]<=l1 then begin if cost[i]+c1<cost[j] then cost[j]:=cost[i]+c1 end else if len[j]-len[i]<=l2 then begin if cost[i]+c2<cost[j] then cost[j]:=cost[i]+c2; end else if cost[i]+c3<cost[j] then cost[j]:=cost[i]+c3; j:=j+1; end; end; writeln(cost[over]); read(i); end. Re: where is the error? I think your error is that the starting stations number can be greater than the destintations number. In this case you just have to swap them. |
|
|