ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1112. Cover

Who can tell me why I got WA?
Posted by Jack(China) 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
for i:=1 to n do
begin
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.
I made a big mistake! Now I got AC.
Posted by Jack(China) 26 Jul 2003 13:33
Re:haha,you are so careless.
Posted by 55555 1 Aug 2003 13:34
> A very careless mistake.It's (-999,999).