记录编号 |
6296 |
评测结果 |
AAAAATTTTT |
题目名称 |
取数字问题 |
最终得分 |
50 |
用户昵称 |
WaterFire |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
5.003 s |
提交时间 |
2008-10-31 20:11:24 |
内存使用 |
0.19 MiB |
显示代码纯文本
program waterfire;
const
fin='number.in';
fout='number.out';
var
num:array[0..1000] of longint;
i,j,t,n,m,k,minnum:longint;
f,data:array[0..100,0..100] of longint;
f1,f2:text;
Procedure sear(a,b,c:longint);
var
ii,jj:longint;
Begin
if (a>m)or(b>n) then exit;
if (a=m)and(b=n) then
if (c<minnum)and(c>0) then minnum:=c;
sear(a+1,b,c+data[a+1,b]);
sear(a,b+1,c+data[a,b+1]);
End;
BEGIN
minnum:=maxlongint;
assign(f1,fin);reset(f1);
assign(f2,fout);rewrite(f2);
readln(f1,m,n);
t:=1;
for i:=1 to m do begin
for j:=1 to n do
read(f1,data[i,j]);
readln(f1);
end;
sear(1,1,data[1,1]);
if minnum=maxlongint then minnum:=-1;
write(f2,minnum);
close(f1);close(f2);
END.