比赛 |
2008haoi模拟训练3 |
评测结果 |
AAAAAAAAAA |
题目名称 |
潜水员的问题 |
最终得分 |
100 |
用户昵称 |
thegy |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-04-24 08:57:37 |
显示代码纯文本
program ple;
var
fin,fout:text;
o0,n0,nn,i,j,k:longint;
o,n,c:array[1..1000]of longint;
f:array[0..21,0..79]of longint;
function min(x,y:longint):longint;
begin
if x<y then min:=x else min:=y;
end;
begin
assign(fin,'ple.in'); reset(fin);
assign(fout,'ple.out'); rewrite(fout);
read(fin,o0,n0,nn);
for i:=1 to nn do
read(fin,o[i],n[i],c[i]);
for i:=0 to o0 do
for j:=0 to n0 do
f[i,j]:=9999999;
f[0,0]:=0;
for k:=1 to nn do
begin
for i:=o0 downto 0 do
for j:=n0 downto 0 do
begin
if (i<=o[k]) and (j<=n[k]) then f[i,j]:=min(f[i,j],f[0,0]+c[k]);
if (i<=o[k]) and (j>n[k]) then f[i,j]:=min(f[i,j],f[0,j-n[k]]+c[k]);
if (i>o[k]) and (j<=n[k]) then f[i,j]:=min(f[i,j],f[i-o[k],0]+c[k]);
if (i>o[k]) and (j>n[k]) then f[i,j]:=min(f[i,j],f[i-o[k],j-n[k]]+c[k]);
end;
end;
writeln(fout,f[o0,n0]);
close(fout);
end.