ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1146. Maximum Sum

Could you help me? I belive it's an AC source
Послано Dinu Adrian Florin 11 май 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
Послано qwe 11 май 2004 14:58
assign(input,'test.txt');reset(input);

delete this line=)
After this operation result is WA on test 5.
Послано Vlad Veselov 11 май 2004 18:04