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

Show all messages Hide all messages

I have found some bugs but still WA, plz help. Ural_Happy New Year! 19 May 2003 19:47
program t1193;
type types=record
           b:longint;
           l:longint;
           e:longint;
           end;
var n,i,start:longint;
    t:array[0..100]of types;
procedure sort;
var j,i:integer;
    y:types;
begin
     for i:=1 to n do
         for j:=i to n do
             if (t[i].b>t[j].b)or((t[i].b=t[j].b)and(t[i].e>t[j].e))
then
                begin
                     y:=t[i];
                     t[i]:=t[j];
                     t[j]:=y;
                end;
end;
begin
     assign(input,'c:\pas\in.txt');
     reset(input);
     readln(n);
     for i:=1 to n do
         readln(t[i].b,t[i].l,t[i].e);
     close(input);
     sort;
     start:=t[1].b;
     for i:=1 to n do
         begin
         start:=start+t[i].l;
         if t[i+1].b>start then start:=t[i+1].b;
         end;
     start:=start-t[n].e;
     if start>0 then writeln(start)
                else writeln(0);
end.
you are too hard ural_li yubo 19 May 2003 20:26
> program t1193;
> type types=record
>            b:longint;
>            l:longint;
>            e:longint;
>            end;
> var n,i,start:longint;
>     t:array[0..100]of types;
> procedure sort;
> var j,i:integer;
>     y:types;
> begin
>      for i:=1 to n do
>          for j:=i to n do
>              if (t[i].b>t[j].b)or((t[i].b=t[j].b)and(t[i].e>t
[j].e))
> then
>                 begin
>                      y:=t[i];
>                      t[i]:=t[j];
>                      t[j]:=y;
>                 end;
> end;
> begin
>      assign(input,'c:\pas\in.txt');
>      reset(input);
>      readln(n);
>      for i:=1 to n do
>          readln(t[i].b,t[i].l,t[i].e);
>      close(input);
>      sort;
>      start:=t[1].b;
>      for i:=1 to n do
>          begin
>          start:=start+t[i].l;
>          if t[i+1].b>start then start:=t[i+1].b;
>          end;
>      start:=start-t[n].e;
>      if start>0 then writeln(start)
>                 else writeln(0);
> end.