a,opt:array[1..100,1..100]of longint;
qu:array[1..100,1..100,1..100]of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a)else exit(b);
end;
begin
read(m,n);
for i:=1 to m do
for j:=1 to n do
read(a[i,j]);
fillchar(opt,sizeof(opt),0);
fillchar(qu,sizeof(qu),0);
for i:=1 to n do begin opt[1,i]:=a[1,i]; end;
for i:=2 to m do
begin
for j:=1 to n do
begin
ma:=-maxlongint;
for k:=1 to j-1 do
if ma<opt[i-1,k]+a[i,j] then
begin
ma:=opt[i-1,k]+a[i,j];
if i>2 then
begin
for l:=1 to i-2 do
qu[i,j,l]:=qu[i-1,k,l];
end;
qu[i,j,i-1]:=k;
end;
opt[i,j]:=max(ma,opt[i,j]);
end;
end;
ma:=-maxlongint;
l:=-maxlongint;
for i:=1 to n do
if ma<opt[m,i] then begin ma:=opt[m,i];L:=i;end;
//for i:=1 to m do begin
//for j:=1 to n do write(opt[i,j],' ');writeln;end;writeln;writeln;
writeln(ma);
ma:=-maxlongint;
l:=-maxlongint;
for i :=1 to n do if ma<opt[m,i] then begin ma:=opt[m,i];l:=i;end;
for i:=1 to m-1 do write(qu[m,l,i],' ');
write(l);
end.
为什么会有开头出现好几个零的?