比赛 |
2008haoi模拟训练3 |
评测结果 |
WTWWTTTATA |
题目名称 |
潜水员的问题 |
最终得分 |
20 |
用户昵称 |
MayLava |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-04-24 10:57:57 |
显示代码纯文本
program MayLava;
type
rec=record
o2,n2,m:longint;
end;
var
q:array[1..1000]of rec;
oo,nn,n,min:longint;
procedure start;
var
i,j:longint;
f:text;
begin
assign(f,'ple.in');
reset(F);
readln(f,oo,nn);
readln(f,n);
for i:=1 to n do
readln(f,q[i].o2,q[i].n2,q[i].m);
close(f);
min:=maxlongint;
end;
procedure hunt(mt,ot,nt,t:longint);
begin
if mt>min then exit;
if t>n then exit;
if (ot>oo) and (nt>nn) and (mt<min) then begin
min:=mt;
exit;
end;
hunt(mt+q[t].m,ot+q[t].o2,nt+q[t].n2,t+1);
hunt(mt,ot,nt,t+1);
end;
procedure print;
var
f:text;
begin
assign(f,'ple.out');
rewrite(f);
writeln(f,min);
close(f);
end;
BEGIN
start;
hunt(0,0,0,1);
print;
END.