Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- a:array[1..500,1..500] of integer;
- n,sum,max,i,j,k,l:longint;
- begin
- assign(input,'table.in');
- assign(output,'table.out');
- reset(input);
- rewrite(output);
- readln(n);
- max:=-1000000000;
- for i:=1 to n do begin
- for j:=1 to n do begin
- read(a[i,j]);
- end;
- readln;
- end;
- for i:=1 to n do begin
- for k:=1 to n do begin
- j:=k;
- l:=i;
- sum:=0;
- while (j<=n) and (l<=n) do begin
- sum:=sum+a[l,j];
- if sum>max then max:=sum;
- inc(j);
- inc(l);
- end;
- end;
- end;
- for i:=n downto 1 do begin
- for k:=1 to n do begin
- j:=k;
- l:=i;
- sum:=0;
- while (j<=n) and (l>=1) do begin
- sum:=sum+a[l,j];
- if sum > max then max:=sum;
- inc(j);
- dec(l);
- end;
- end;
- end;
- writeln(max);
- close(input);
- close(output);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement