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 1193. Queue at the Exam

Why I got "Wrang Answer"????
Posted by qwt 3 Mar 2002 08:07
var
  a:array[1..100,1..3] of longint;
  x:array[1..100] of longint;
  t,n,i,j,k,now:longint;
begin
  readln(n);
  for i:=1 to n do begin
    x[i]:=i;
    readln(a[i,1],a[i,2],a[i,3]);
  end;
  for i:=1 to n-1 do for j:=i+1 to n do
    if a[x[i],1]>a[x[j],1] then begin
      k:=x[i];
      x[i]:=x[j];
      x[j]:=k;
    end;
  t:=0;now:=a[x[1],1];
  for i:=1 to n do begin
    if now<a[x[i],1] then now:=a[x[i],1];
    inc(now,a[x[i],2]);
    if now>a[x[i],3] then begin
      inc(t,now-a[x[i],3]);
      now:=a[x[i],3];
    end;
  end;
  writeln(t);
end.
Re: Why I got "Wrang Answer"????
Posted by raxtinhac 3 Mar 2002 16:59
> var
>   a:array[1..100,1..3] of longint;
>   x:array[1..100] of longint;
>   t,n,i,j,k,now:longint;
> begin
>   readln(n);
>   for i:=1 to n do begin
>     x[i]:=i;
>     readln(a[i,1],a[i,2],a[i,3]);
>   end;
>   for i:=1 to n-1 do for j:=i+1 to n do
>     if a[x[i],1]>a[x[j],1] then begin
>       k:=x[i];
>       x[i]:=x[j];
>       x[j]:=k;
>     end;
>   t:=0;now:=a[x[1],1];
>   for i:=1 to n do begin
>     if now<a[x[i],1] then now:=a[x[i],1];
>     inc(now,a[x[i],2]);
>     if now>a[x[i],3] then
      begin
>       {inc(t,now-a[x[i],3]);}
          -> t is max of different beetween now and a[x[i],3] not
                    sum of different.
>       {now:=a[x[i],3]; } -> now is still remain, don't change it.
>     end;
>   end;
>   writeln(t);
> end.