记录编号 |
8180 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[BYVoid S3] 艾萨拉的激流 |
最终得分 |
100 |
用户昵称 |
SMXX |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
4.788 s |
提交时间 |
2008-11-13 11:46:32 |
内存使用 |
0.12 MiB |
显示代码纯文本
program df;
var
f1,f2:text;
a:array[1..1000]of longint;
f:array[0..1,1..1000] of longint;
m,ans,w,l,i,j,x,y,z:longint;
function max(x,y,z:longint):longint;
var
m:longint;
begin
m:=-3;
if x>m then m:=x;
if y>m then m:=y;
if z>m then m:=z;
max:=m;
end;
begin
assign(f1,'azshara.in');
assign(f2,'azshara.out');
reset(f1);
rewrite(f2);
readln(f1,w,l);
m:=0;
for i:= 1to w do begin f[0,i]:=0;f[1,i]:=0;a[i]:=0;end;
for i:= 1to w do begin read(f1,a[i]);
if a[i]>=0 then f[m,i]:=a[i]
else f[m,i]:=-1;
end;
for j:=2 to l do begin
for i:= 1 to w do begin
read(f1,a[i]);
if (i-1>=1)and(a[i]>=0)and(f[m,i-1]>=0) then x:=f[m,i-1]+a[i]
else x:=-1;
if (a[i]>=0)and(f[m,i]>=0) then y:=f[m,i]+a[i]
else y:=-1;
if (a[i]>=0)and(i+1<=w)and(f[m,i+1]>=0)then z:=f[m,i+1]+a[i]
else z:=-1;
f[1-m,i]:=max(x,y,z);
end;
m:=1-m;
end;
ans:=-1;
for i:= 1 to w do if f[m,i]>ans then ans:=f[m,i];
writeln(f2,ans);
close(f1);
close(f2);
end.