3 a
,f
:array [0..25,0..25] of longint;
5 function max(x
,y
: longint):longint;
7 if x
>y
then exit(x
) else exit(y
);
15 for i
:=1 to n
div 2 do inc(f
[n
div 2,n
div 2],a
[i
,i
]);
16 for i
:=n
div 2 +1 to n
do
17 for j
:=n
div 2 to i
do
18 f
[i
,j
]:=max(f
[i
-1,j
],f
[i
-1,j
-1])+a
[i
,j
];
20 f
[n
,n
]:=max(f
[n
,n
],f
[n
,i
]);