比赛 NOIP2008集训模拟4 评测结果 AAAAAAAAAA
题目名称 艾萨拉的激流 最终得分 100
用户昵称 zxc111 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 09:04:57
显示代码纯文本
program ooo;
var
i,j,k,n,m,max:longint;
t:text;
a,b:array[0..10001,0..1001] of longint;
f:array[0..10001,0..1001] of boolean;
begin
assign(t,'azshara.in');
reset(t);
readln(t,n,m);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(f,sizeof(f),false);
for i:=1 to m do
 begin
  for j:=1 to n do
   read(t,a[i,j]);
  readln(t);
 end;
close(t);
for i:=1 to n do
begin
f[1,i]:=true;
b[1,i]:=a[1,i];
end;
for i:=2 to m do
 begin
  for j:=1 to n do
   if (a[i,j]<>-1) then
    begin
     f[i,j]:=true;
     if b[i-1,j]+a[i,j]>b[i,j] then b[i,j]:=b[i-1,j]+a[i,j];
     if b[i-1,j-1]+a[i,j]>b[i,j] then b[i,j]:=b[i-1,j-1]+a[i,j];
     if b[i-1,j+1]+a[i,j]>b[i,j] then b[i,j]:=b[i-1,j+1]+a[i,j];
    end;
 end;
max:=0;
for i:=1 to n do
 if max<b[m,i] then max:=b[m,i];
assign(t,'azshara.out');
rewrite(t);
write(t,max);
close(t);
end.