比赛 NOIP2008集训模拟4 评测结果 AWAAAAAAAA
题目名称 艾萨拉的激流 最终得分 90
用户昵称 name:弓虽 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 10:23:29
显示代码纯文本
program azshara;
var
  i,j,k:longint;
  ans:longint;
  w,l:longint;
  head,tail:longint;
  judge:boolean;
  map:array[0..2,1..10000]of longint;
begin
  assign(input,'azshara.in');
  assign(output,'azshara.out');
  reset(input);
  rewrite(output);
  readln(w,l);
  head:=0;
  tail:=1;
  fillchar(map,sizeof(map),0);
  for i:=1 to l do
  begin


    for j:=1 to w do
      read(map[2,j]);
    readln;

    for k:=1 to w do
    begin

      judge:=false;
      if k-1>0 then
      if (map[tail,k-1]+map[2,k]>map[head,k])and(map[tail,k-1]<>-1)
      then begin
        map[head,k]:=map[tail,k-1]+map[2,k];
        judge:=true;
      end;
      if (map[tail,k]+map[2,k]>map[head,k])and(map[tail,k]<>-1)
      then begin
        map[head,k]:=map[tail,k]+map[2,k];
        judge:=true;
      end;

      if k+1<=w then
      if (map[tail,k+1]+map[2,k]>map[head,k])and(map[tail,k+1]<>-1)
       then begin
        map[head,k]:=map[tail,k+1]+map[2,k];
        judge:=true;
      end;
      if judge=false then map[head,k]:=-1;
    end;

    head:=tail;
    tail:=abs(head-1);
  end;
  ans:=0;
  for i:=1 to w do
    if map[tail,i]>ans then ans:=map[tail,i];
  writeln(ans);
  close(input);
  close(output);
end.