ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1031. Railway Tickets

Why I got WA? HELP!!!!!
Posted by Bighead 20 Apr 2002 09:16
I think my program is right, but it got WA, why? Could you help me?

Here is my code:

const
  maxnum=1000000000;
var
    best,i,j,dis,cost:cardinal;
  begin
    for i:=s+1 to t do begin
      best:=maxnum;
      for j:=i-1 downto s do begin
        if f[j]=maxnum then continue;
        dis:=abs(len[i]-len[j]);
        if dis>l[3] then break
          else if dis>l[2] then cost:=c[3]
            else if dis>l[1] then cost:=c[2]
              else cost:=c[1];
        if cost>=maxnum then break
          else if cost+f[j]<best then best:=cost+f[j];
      end;
      if best<maxnum then f[i]:=best;
    end;
    writeln(f[t]);
  end;

begin
  for i:=1 to 3 do read(l[i]);
  for i:=1 to 3 do read(c[i]);
  readln(n);
  readln(s,t);
  if s>t then begin
    i:=s;
    s:=t;
    t:=i;
  end;
  if s=t then begin writeln(0);halt;end;
  for i:=2 to t do begin
    read(len[i]);
    f[i]:=maxnum;
  end;
  f[s]:=0;
  solve;
end.
Oh, now it is accepted. The tests contains two stations which are at the same position!
Posted by Bighead 20 Apr 2002 11:54