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 1112. Cover

Jack(China) Who can tell me why I got WA? [2] // Problem 1112. Cover 26 Jul 2003 07:45
This is my program.

var long:array [1..500,1..3] of integer;
    num:array [1..500,1..2] of integer;
    max,i,j,l,n:integer;

begin
  read(n);
  for i:=1 to n do
  begin
    read(num[i,1],num[i,2]);
    if num[i,1]>num[i,2] then
      begin j:=num[i,1]; num[i,1]:=num[i,2]; num[i,2]:=j; end;
  end;
  for i:=1 to n-1 do
   for j:=i+1 to n do
    if (num[i,1]>num[j,1]) or
     ((num[i,1]=num[j,1]) and (num[i,2]>num[j,2])) then
     begin
       l:=num[i,1]; num[i,1]:=num[j,1]; num[j,1]:=l;
       l:=num[i,2]; num[i,2]:=num[j,2]; num[j,2]:=l;
     end;
  for i:=1 to n do long[i,1]:=num[i,2]-num[i,1];
  for i:=1 to n do long[i,3]:=1;
  for i:=n-1 downto 1 do
    for j:=n downto i+1 do
      if (num[i,2]<=num[j,1]) then
        if long[j,1]+num[i,2]-num[i,1]>long[i,1] then
          begin long[i,1]:=long[j,1]+num[i,2]-num[i,1]; long[i,2]:=j;
long[i,3]:=long[j,3]+1; end;
  max:=1;
  for i:=2 to n do
   if long[i,1]>long[max,1] then max:=i;
  writeln(long[max,3]);
  while long[max,2]<>0 do
   begin
     writeln(num[max,1],' ',num[max,2]);
     max:=long[max,2];
   end;
  writeln(num[max,1],' ',num[max,2]);
end.
Jack(China) I made a big mistake! Now I got AC. [1] // Problem 1112. Cover 26 Jul 2003 13:33
55555 Re:haha,you are so careless. // Problem 1112. Cover 1 Aug 2003 13:34
> A very careless mistake.It's (-999,999).