记录编号 |
5936 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[IOI 1994] 数塔 |
最终得分 |
100 |
用户昵称 |
Hamster |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.006 s |
提交时间 |
2008-10-29 20:23:08 |
内存使用 |
0.23 MiB |
显示代码纯文本
program shuta;
var
a,b,c:array[1..100,1..100] of longint;
i,j,n:longint;
fin,fout:text;
procedure init;
begin
readln(fin,n);
for i:=1 to n do
for j:=1 to i do
begin
read(fin,a[i,j]);
b[i,j]:=a[i,j];
c[i,j]:=0;
end;
end;
begin
assign(fin,'shuta.in');
assign(fout,'shuta.out');
reset(fin);
rewrite(fout);
init;
for i:=n-1 downto 1 do
for j:=1 to i do
if a[i+1,j]>a[i+1,j+1] then
begin
a[i,j]:=a[i+1,j]+a[i,j];
c[i,j]:=0;
end
else
begin
a[i,j]:=a[i+1,j+1]+a[i,j];
c[i,j]:=1;
end;
writeln(fout,a[1,1]);
j:=1;
for i:=1 to n do
begin
write(fout,b[i,j],' ');
j:=j+c[i,j];
end;
close(fin);
close(fout);
end.