比赛 NOIP2008集训模拟4 评测结果 AAAAAAAAAA
题目名称 艾萨拉的激流 最终得分 100
用户昵称 thegy 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 09:22:57
显示代码纯文本
program azshara;
var
  fin,fout:text;
  f:array[0..1,1..1000]of longint;
  a:array[1..1000]of longint;
  k:array[1..3]of longint;
  w,l,i,j,p,kk,ans:longint;
function hf(x:longint):boolean;
begin
  if (1<=x) and (x<=w) then hf:=true else hf:=false;
end;
procedure updata(var x:longint;y:longint);
begin
  if y>x then x:=y;
end;
begin
  k[1]:=-1; k[2]:=0; k[3]:=1;
  assign(fin,'azshara.in'); reset(fin);
  assign(fout,'azshara.out'); rewrite(fout);
  read(fin,w,l);
  for i:=1 to w do f[0,i]:=0;
  p:=0;
  for i:=1 to l do begin
    p:=1-p;
    for j:=1 to w do read(fin,a[j]);
    for j:=1 to w do begin
      f[p,j]:=(-1)*(maxlongint-1);
      if a[j]<>-1 then
        for kk:=1 to 3 do
          if hf(j+k[kk]) then updata(f[p,j],f[1-p,j+k[kk]]+a[j]);
    end;
  end;
  ans:=(-1)*(maxlongint-1);
  for i:=1 to w do
    if f[p,i]>ans then ans:=f[p,i];
  writeln(fout,ans);
  close(fin);
  close(fout);
end.