记录编号 |
15335 |
评测结果 |
AAAAAAAAAA |
题目名称 |
取数字问题 |
最终得分 |
100 |
用户昵称 |
chengyang |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.020 s |
提交时间 |
2009-11-11 20:00:18 |
内存使用 |
0.50 MiB |
显示代码纯文本
program number;
var
a:array[0..21,0..21,-420..420]of boolean;
b:array[0..21,0..21]of longint;
i,j,n,m,k:longint;
begin
assign(input,'number.in');
assign(output,'number.out');
reset(input); rewrite(output);
readln(m,n);
fillchar(b,sizeof(b),0);
fillchar(a,sizeof(a),0);
for i:=1 to m do begin
for j:=1 to n do read(b[i,j]);
readln;
end;
a[1,1,b[1,1]]:=true;
for i:=1 to m do begin
for j:=1 to n do begin
for k:=-400 to 400 do begin
if a[i,j,k] then begin
a[i+1,j,k+b[i+1,j]]:=true;
a[i,j+1,k+b[i,j+1]]:=true;
end;
end;
end;
end;
k:=-1; i:=1;
repeat
if a[m,n,i] then k:=i
else inc(i);
until (k>0)or(i=400);
writeln(k);
close(input); close(output);
end.