比赛 NOIP2008集训模拟4 评测结果 AAAAAAAAAA
题目名称 艾萨拉的激流 最终得分 100
用户昵称 卐祭司卐 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 10:36:59
显示代码纯文本
program azshara;
const
  maxw=1000;
  maxl=10000;
var
  i,j:longint;
  w,l,k:integer;
  fi,fo:text;
  x,m:array[0..maxl+1,0..maxw+1] of longint;

begin
  assign(fi,'azshara.in');
  assign(fo,'azshara.out');
  reset(fi);
  rewrite(fo);
  readln(fi,w,l);
  for i:=1 to l do
   for j:=1 to w do read(fi,x[i,j]);
  for i:=1 to w do m[l,i]:=x[l,i];
  for i:=1 to l do begin m[l,0]:=-1; m[l,w+1]:=-1; end;

  for i:=l-1 downto 1 do
   for j:=1 to w do
    if x[i,j]<>-1 then
    begin
     if (m[i+1,j-1]>=m[i+1,j])and(m[i+1,j-1]>=m[i+1,j+1])
     and(x[i+1,j-1]<>-1) then
       m[i,j]:=x[i,j]+m[i+1,j-1];

     if (m[i+1,j]>=m[i+1,j-1])and(m[i+1,j]>=m[i+1,j+1])
     and(x[i+1,j]<>-1) then
       m[i,j]:=x[i,j]+m[i+1,j];

     if (m[i+1,j+1]>=m[i+1,j])and(m[i+1,j+1]>=m[i+1,j-1])
     and(x[i+1,j+1]<>-1) then
       m[i,j]:=x[i,j]+m[i+1,j+1];
    end
    else m[i,j]:=-1;
  j:=-1;
  for i:=1 to w do if x[1,i]<>-1 then if m[1,i]>j then j:=m[1,i];
  write(fo,j);
  close(fi);
  close(fo);
end.