分析
这题要用到
程序:
uses math;
var
n,i,j,k,ans:longint;
a,y,x:array[0..500,0..500]of longint;
begin
readln(n);
for i:=1 to n do
for j:=1 to n do
begin
read(a[i,j]);
x[i,j]:=x[i-1,j-1]+a[i,j];
end;
for i:=1 to n do
for j:=n downto 1 do
y[i,j]:=y[i-1,j+1]+a[i,j];
for i:=2 to n do
for j:=2 to n do
for k:=2 to min(i,j) do
ans:=max(ans,(x[i,j]-x[i-k,j-k])-(y[i,j-k+1]-y[i-k,j+1]));
write(ans);
end.