type shu=array[0..500]of longint;
const maxn=80;
var a:array[0..maxn]of longint;
f:array[0..maxn,0..maxn]of shu;
i,j,k,m,n:longint;
zero,ans:shu;
l:longint;
t1,t2,t3,t4:shu;
function max(aa,bb:shu):shu;
var ii:longint;
begin
for ii:=400 downto 0 do
begin
if aa[ii]<bb[ii] then exit(bb);
if aa[ii]>bb[ii] then exit(aa);
end;
exit(aa);
end;
function add(aa:shu;bb:longint):shu;
var ii:longint;
begin
inc(aa[1],bb);
ii:=1;
while aa[ii]>9 do
begin
inc(aa[ii+1],aa[ii] div 10);
aa[ii]:=aa[ii] mod 10;
end;
exit(aa);
end;
procedure print(aa:shu);
var ii,ll:longint;
begin
ll:=400;
while (aa[ll]=0)and(ll>1) do dec(ll);
for ii:=ll downto 1 do write(aa[ii]);
writeln;
end;
function x2(aa:shu):shu;
var ii,ll:longint;
begin
ll:=400;
while (aa[ll]=0)and(ll>1) do dec(ll);
for ii:=1 to ll do aa[ii]:=aa[ii]*2;
for ii:=1 to ll do
begin
aa[ii+1]:=aa[ii+1]+aa[ii] div 10;
aa[ii]:=aa[ii]mod 10;
end;
exit(aa);
end;
function sum(aa,bb:shu):shu;
var cc:shu;
ii,ll:longint;
begin
ll:=400;
while (ll>1)and(aa[ll]=0)and(bb[ll]=0) do dec(ll);
for ii:=1 to ll do cc[ii]:=aa[ii]+bb[ii];
for ii:=1 to ll do
begin
cc[ii+1]:=cc[ii+1]+cc[ii] div 10;
cc[ii]:=cc[ii] mod 10;
end;
exit(cc);
end;
{main}
begin
readln(n,m);
for i:=0 to 400 do zero[i]:=0;
for n:=1 to n do
begin
for i:=1 to m do read(a[i]);
for i:=1 to m do f[i,i]:=x2(add(zero,a[i]));
for k:=1 to m-1 do
for i:=1 to m-k do
begin
j:=i+k;
f[i,j]:=x2(max(add(f[i+1,j],a[i]),add(f[i,j-1],a[j])));
// write(i,',',j,':');print(f[i,j]);
end;
ans:=sum(ans,f[1,m]);
end;
print(ans);
end.
存下程序,有空慢慢调。