记录编号 8287 评测结果 AAAAAAAAAA
题目名称 [BYVoid S3] 艾萨拉的激流 最终得分 100
用户昵称 Gravatarmaxiem 是否通过 通过
代码语言 Pascal 运行时间 5.678 s
提交时间 2008-11-13 15:01:09 内存使用 76.41 MiB
显示代码纯文本
program azshara;
const d:array [1..3,1..2] of shortint=((1,1),(1,0),(1,-1));
var
  f,table:array [1..10000,1..1000] of longint;
  tx,ty,w,l,i,j,k,max,sum:longint;
begin
  fillchar (f,sizeof(f),$FF);
  assign (input,'azshara.in');
  reset (input);
  readln (l,w);
  for i:=1 to w do begin
    for j:=1 to l do read (table[i,j]);
    readln;
  end;
  close (input);
  for i:=1 to l do f[1,i]:=table[1,i];
  assign (output,'azshara.out');
  rewrite (output);
  for i:=2 to w do for j:=1 to l do if table[i,j]<>-1 then begin
    sum:=0;max:=0;
    for k:=1 to 3 do begin
      tx:=i-d[k,1];ty:=j-d[k,2];
      if (tx>=1) and (ty>=1) and (ty<=l) then sum:=table[i,j]+f[tx,ty];
      if sum>max then max:=sum;
    end;
    f[i,j]:=max;
  end;
  max:=0;
  for i:=1 to l do if f[w,i]>max then max:=f[w,i];
  writeln (max);
  close (output);
end.