错了错了,看下面一楼的我重发的
var
i,j,n:integer;
a,pre,count:array[1..20] of integer;
con:array[1..20,1..20] of integer;
first:boolean;
procedure print(a:integer);
begin
if pre[a]<>0
then
print(pre[a]);
if first
then first:=false
else write('-');
write(a);
end;
begin
read(n);
for i:=1 to n do
read(a);
for i:=1 to n-1 do
for j:=i+1 to n do
read(con[i,j]);
for i:=1 to n do
begin
count:=a;
pre:=0;
end;
for i:=2 to n do
for j:=1 to i-1 do
if (count[j]+a>count) and (con[j,i]=1)
then
begin
count:=count[j]+a;
pre:=j;
end;
j:=1;
for i:=1 to n do
if count>count[j]
then
j:=i;
first:=true;
print(j);
writeln;
write('max=',count[j]);
end.