比赛 |
暑假培训七 |
评测结果 |
C |
题目名称 |
数塔 |
最终得分 |
0 |
用户昵称 |
E.M.B.E.R |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-07-24 15:11:45 |
显示代码纯文本
program EmberAsh;
var
a:array[1..50,1..50,1..3] of longint;
i,j,k,n:longint;
fin,fout:text;
BEGIN
assign(fin,'shuta.in');
assign(fout,'shuta.out');
reset(fin);rewrite(fout);
readln(fin,n);
for i:=1 to n do
for j:=1 to i do
begin
read(fin,a[i,j,1]);
a[i,j,2]:=a[i,j,1];
a[i,j,3]:=0
end;
for i:=n-1 downto 1 do
for j:=1 to i do
if a[i+1,j,2]>a[i+1,j+1,2] then
begin
a[i,j,2]:=a[i,j,2]+a[i+1,j,2];a[i,j,3]:=0;
end
else
begin
a[i,j,2]:=a[i,j,2]+a[i+1,j+1,2];
a[i,j,3]:=1;
end;
writeln(fout,a[1,1,2]);
j:=1;
for i:=1 to n-1 do
begin
write(fout,a[i,j,1],' ');
j:=j+a[i,j,3];
end;
writeln(fout,a[n,j,1])
close(fin);close(fout);
END.