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

Who can help me?
Posted by TaoZhang 21 Oct 2002 17:19
Here is my program(WA):
var
 a:array[1..100,1..2]of longint;
 b:array[1..100]of longint;
 max,i,n,t1,j:longint;

begin
 readln(n);
 for i:=1 to n do readln(a[i,1],b[i],a[i,2]);
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if a[i,1]>a[j,1] then
    begin
     t1:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t1;
     t1:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t1;
     t1:=b[i];b[i]:=b[j];b[j]:=t1;
    end;
 max:=a[1,1]+b[1];
 for i:=2 to n do
  if max<a[i,1] then max:=a[i,1]+b[i] else j:=max+b[i];
 if j>a[n,2] then write(j-a[n,2]) else write(0);
end.
Re: Who can help me?
Posted by gc007 30 Oct 2002 15:16
> Here is my program(WA):
> var
>  a:array[1..100,1..2]of longint;
>  b:array[1..100]of longint;
>  max,i,n,t1,j:longint;
>
> begin
>  readln(n);
>  for i:=1 to n do readln(a[i,1],b[i],a[i,2]);
>  for i:=1 to n-1 do
>   for j:=i+1 to n do
>    if a[i,1]>a[j,1] then
>     begin
>      t1:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t1;
>      t1:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t1;
>      t1:=b[i];b[i]:=b[j];b[j]:=t1;
>     end;
>  max:=a[1,1]+b[1];
>  for i:=2 to n do
>   if max<a[i,1] then max:=a[i,1]+b[i] else j:=max+b[i];
>  if j>a[n,2] then write(j-a[n,2]) else write(0);
> end.
>
Tao Zhang is really a fool,a cheater.
Posted by gc007 30 Oct 2002 15:17
> Here is my program(WA):
> var
>  a:array[1..100,1..2]of longint;
>  b:array[1..100]of longint;
>  max,i,n,t1,j:longint;
>
> begin
>  readln(n);
>  for i:=1 to n do readln(a[i,1],b[i],a[i,2]);
>  for i:=1 to n-1 do
>   for j:=i+1 to n do
>    if a[i,1]>a[j,1] then
>     begin
>      t1:=a[i,1];a[i,1]:=a[j,1];a[j,1]:=t1;
>      t1:=a[i,2];a[i,2]:=a[j,2];a[j,2]:=t1;
>      t1:=b[i];b[i]:=b[j];b[j]:=t1;
>     end;
>  max:=a[1,1]+b[1];
>  for i:=2 to n do
>   if max<a[i,1] then max:=a[i,1]+b[i] else j:=max+b[i];
>  if j>a[n,2] then write(j-a[n,2]) else write(0);
> end.
>