比赛 |
NOIP2008集训模拟4 |
评测结果 |
ATAATTTTTT |
题目名称 |
艾萨拉的激流 |
最终得分 |
30 |
用户昵称 |
E.M.B.E.R |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-13 09:23:55 |
显示代码纯文本
program EmberAsh;
var
a:array[0..10000,0..1000]of longint;
f:array[0..10000,0..1000]of longint;
i,j,k,n,m,w,l,max,jj:longint;
fin,fout:text;
procedure try(x,y,s:longint);
var
i,j,k,x1,y1,s1:longint;
begin
if s>max then max:=s;//处理特殊情况
if (x+1<=l)and(y-1>=0)and(a[x+1,y-1]<>-1)and(s+a[x+1,y-1]>f[x+1,y-1]) then
begin
x1:=x+1;y1:=y-1;s1:=s+a[x+1,y-1];
f[x+1,y-1]:=s1;
if s1>max then max:=s1;
try(x1,y1,s1);
end;//左
if (x+1<=l)and(a[x+1,y]<>-1)and(s+a[x+1,y]>f[x+1,y]) then
begin
x1:=x+1;y1:=y;s1:=s+a[x+1,y];
f[x+1,y]:=s1;
if s1>max then max:=s1;
try(x1,y1,s1);
end;//前
if (x+1<=l)and(y+1<=w)and(a[x+1,y+1]<>-1)and(s+a[x+1,y+1]>f[x+1,y+1]) then
begin
x1:=x+1;y1:=y+1;s1:=s+a[x+1,y+1];
f[x+1,y+1]:=s1;
if s1>max then max:=s1;
try(x1,y1,s1);
end;
end;
BEGIN
assign(fin,'azshara.in');reset(fin);
assign(fout,'azshara.out');rewrite(fout);
readln(fin,w,l);
for i:=1 to l do
for j:=1 to w do
read(fin,a[i,j]);
jj:=0;
for i:=1 to w do
if a[1,i]<>-1 then
begin
//max:=0;
//fillchar(f,sizeof(f),0);
try(1,i,a[1,i]);//x,y,s
//if (jj=maxlongint)or(jj<max) then jj:=max;
end;
//writeln(fout,jj);
for i:=1 to w do
if f[l,i]>jj then jj:=f[l,i];
writeln(fout,jj);
close(fin);close(fout);
END.