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 1146. Maximum Sum

Could you help me? I belive it's an AC source
Posted by Dinu Adrian Florin 11 May 2004 14:54
var x,y,d1,d2:array[0..100,0..100] of longint;
i,j,s1,s2,k,l,m,n:longint;
begin
assign(input,'test.txt');reset(input);
readln(n);
for i:=1 to n+1 do
begin
x[i,0]:=-99;
x[0,i]:=-99;
end;
for i:=1 to n do
for j:=1 to n do
read(x[i,j]);
for i:=1 to n do
for j:=1 to n do
begin
y[i,j]:=x[i,j];
d1[i,j]:=i;
d2[i,j]:=j;
s1:=0; s2:=0;
for k:=d1[i-1,j-1] to i-1 do inc(s1,x[k,j]);
for k:=d2[i-1,j-1] to j-1 do inc(s2,x[i,k]);
if s1+s2+y[i-1,j-1]+x[i,j]>y[i,j] then
                                  begin
                                  y[i,j]:=s1+s2+y[i-1,j-1]+x[i,j];
                                  d1[i,j]:=d1[i-1,j-1];
                                  d2[i,j]:=d2[i-1,j-1];
                                  end;
s1:=0; s2:=0;
for k:=d2[i-1,j] to j-1 do inc(s2,x[i,k]);
if s2+y[i-1,j]+x[i,j]>y[i,j] then
                             begin
                             y[i,j]:=s2+y[i-1,j]+x[i,j];
                             d1[i,j]:=d1[i-1,j];
                             d2[i,j]:=d2[i-1,j];
                             end;

s1:=0; s2:=0;
for k:=d1[i,j-1] to i-1 do inc(s1,x[k,j]);
if s1+y[i,j-1]+x[i,j]>y[i,j] then
                             begin
                             y[i,j]:=s1+y[i,j-1]+x[i,j];
                             d1[i,j]:=d1[i,j-1];
                             d2[i,j]:=d2[i,j-1];
                             end;

end;
m:=y[1,1];
for i:=1 to n do
for j:=1 to n do
if y[i,j]>m then m:=y[i,j];
writeln(m);
end.

Every test I tried works. What is wrong with it?
Re: Could you help me? I belive it's an AC source
Posted by qwe 11 May 2004 14:58
assign(input,'test.txt');reset(input);

delete this line=)
After this operation result is WA on test 5.
Posted by Vlad Veselov 11 May 2004 18:04