比赛 |
暑假培训七 |
评测结果 |
AAAAAAAAWW |
题目名称 |
数塔 |
最终得分 |
80 |
用户昵称 |
Hamster |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-24 15:36:45 |
显示代码纯文本
program num;
var
a,f:array [1..80,1..80] of longint;
st:string;
i,j,n:integer;
f1,f2:text;
path:array [1..80] of string;
begin
assign (f1,'shuta.in');
assign (f2,'shuta.out');
reset (f1);
rewrite (f2);
readln (f1,n);
for i:=1 to n do
begin
for j:=1 to i do
read (f1,a[i,j]);
readln (f1);;
end;
for i:=1 to n do begin
f[n,i]:=a[n,i];
str (a[n,i],st);
path [i]:=path [i]+' '+st;
end;
for i:=n-1 downto 1 do
for j:=1 to i do
begin
if f[i+1,j]<f[i+1,j+1] then begin f[i,j]:=a[i,j]+f[i+1,j+1];
str (a[i,j],st);
path [j]:=st+' '+path [j+1];
end
else begin
f[i,j]:=a[i,j]+f[i+1,j];
str (a[i,j],st);
path [j]:=st+' '+path [j];
end;
end;
writeln (f2,f[1,1]);
writeln (f2,path [1]);
close (f1);
close (f2);
end.