比赛 暑假培训七 评测结果 AAAAATTTTT
题目名称 数塔 最终得分 50
用户昵称 zpl123 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-07-24 16:52:57
显示代码纯文本
program shuta;
const
maxline=80;

var
line:integer;
a:array[1..maxline,1..maxline] of integer;
b:array[1..maxline] of integer;

function maxsum(i,j:integer):integer;
begin
if i=line then
 maxsum:=a[i,j]
 else if maxsum(i+1,j)>maxsum(i+1,j+1)
      then maxsum:=maxsum(i+1,j)+a[i,j]
      else maxsum:=maxsum(i+1,j+1)+a[i,j];
 b[i]:=a[i,j];
 end;

procedure ini;
var
i,j:integer;
begin
assign(input,'shuta.in');
reset(input);
assign(output,'shuta.out');
rewrite(output);
readln(line);
for i:=1 to line do
 begin
 for j:=1 to i do
 read(a[i,j]);
 readln;
 end;
close(input);
end;

procedure main;
var
i,j:integer;
begin
b[1]:=a[1,1];
writeln(maxsum(1,1));
end;

procedure print;
var
i:integer;
begin
for i:=1 to line do write(b[i],' ');
close(output);
end;

begin
ini;
main;
print;
end.