比赛 NOIP2008集训模拟4 评测结果 AAAAAAAAAA
题目名称 艾萨拉的激流 最终得分 100
用户昵称 cuixiaofei 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 10:50:08
显示代码纯文本
//na                            :cuixiaofei;
//da                            :08_11_13;
program azshara;
  var
    n,m,chu                     :longint;
    a                           :array[1..2,-3..10000] of longint;
    f1,f2                       :text;
  function max3(x,y,z:longint):longint;
    var
      t                         :longint;
  begin
    t:=x;
    if t<y then
      t:=y;
    if t<z then
      t:=z;
    max3:=t;
  end;
  procedure caozuo(b:longint);
    var
      i,ji                      :longint;
  begin
    for i:=1 to n do
      if a[b,i]<>-1 then
        begin
          ji:=max3(a[3-b,i-1],a[3-b,i],a[3-b,i+1]);
          if ji<>-1 then
            a[b,i]:=ji+a[b,i]
          else
            a[b,i]:=-1;
        end;
  end;
  procedure init;
    var
      i,j,b                     :longint;
  begin
    assign(f1,'azshara.in');
    reset(f1);
    assign(f2,'azshara.out');
    rewrite(f2);
    chu:=-1;
    filldword(a,sizeof(a) div 4,-1);
    readln(f1,n,m);
    for i:=1 to n do
      read(f1,a[1,i]);
    b:=2;
    for i:=2 to m do
      begin
        for j:=1 to n do
          read(f1,a[b,j]);
        caozuo(b);
        b:=3-b;
      end;
    b:=3-b;
    for i:=1 to n do
      if a[b,i]>chu then
        chu:=a[b,i];
  end;
  procedure print;
  begin
    writeln(f2,chu);
    close(f1);
    close(f2);
  end;
  begin
    init;
    print;
  end.