比赛 |
2008haoi模拟训练3 |
评测结果 |
ATATTTTTTA |
题目名称 |
潜水员的问题 |
最终得分 |
30 |
用户昵称 |
SMXX |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-04-24 08:41:07 |
显示代码纯文本
program ple;
var
f1,f2:text;
n,t,a,i,j,min:integer;
c:array[1..1000,1..3]of integer;
b:array[1..1000]of boolean;
procedure find;
var i,j,k:integer;
o:array[1..3]of integer;
begin
fillchar(o,sizeof(o),0);
for j:= 1 to 3 do
for i:= 1 to n do
if b[i] then o[j]:=o[j]+c[i,j];
if (o[1]>=t)and(o[2]>=a)then
if o[3]<min then min:=o[3];
end;
procedure def(p:integer);
var i,j,k,g,h:integer;
begin
if p<n then begin
for i:= 1 to n do
if not b[i] then begin
b[i]:=true;inc(p);
find;def(p);
b[i]:=false;
dec(p);
end;
end;
end;
begin
assign(f1,'ple.in');
assign(f2,'ple.out');
reset(f1);
rewrite(f2);
readln(f1,t,a);
readln(f1,n);
for i:= 1 to n do readln(f1,c[i,1],c[i,2],c[i,3]);
min:=maxint;
fillchar(b,sizeof(b),0);
def(0);
writeln(f2,min);
close(f1);
close(f2);
end.