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 WA? help help help~!~!~!~!~!
Posted by bingo2002 21 Apr 2002 00:06
type
  info=record
     s:integer;
     f:integer;
     e:integer;
  end;
var
   stu:array[1..101]of info;
   n,i,j:integer;
   temp:info;
   extra,sum:integer;
begin
   readln(n);
   for i:=1 to n do
     readln(stu[i].s,stu[i].f,stu[i].e);
   for i:=1 to n-1 do
     for j:=1 to i do
       begin
         if stu[j].s>stu[j+1].s then
            begin
               temp:=stu[j];
               stu[j]:=stu[j+1];
               stu[j+1]:=temp;
            end;
       end;
   extra:=0;
   for i:=1 to n do
     begin
        sum:=stu[i].s+stu[i].f;
        if sum>stu[i].e then
          if (sum-stu[i].e)>extra then
             extra:=sum-stu[i].e;
        if sum>stu[i+1].s then
             stu[i+1].s:=sum;
     end;
   write(extra);
   readln;
end.