比赛 |
2008haoi模拟训练3 |
评测结果 |
AWWAEWWWWA |
题目名称 |
潜水员的问题 |
最终得分 |
30 |
用户昵称 |
WaterFire |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-04-24 09:59:50 |
显示代码纯文本
program waterfire;
const
fin='ple.in';
fout='ple.out';
type
y=array[1..1000,1..3] of longint;
bit=array[1..1000]of longint;
var
n,t,a,i,j,k,v:longint;
p:y;
f,g:text;
s:bit;
function prefer(r:longint):longint;
var
i,j:longint;
begin
if v>r then
v:=r;
end;
procedure try(c:y);
var
i,j:integer;
begin
for i:= 1 to n do
begin
if (c[i,1]>=t)and(c[i,2]>=a) then
begin
s[k]:=c[i,3];
if k=1 then v:=s[k]
else prefer(s[k]);
inc(k);
end else
for j:= 1 to n do
if (c[j,1]<>c[i,1]) and (c[i,2]<>c[j,2]) and (c[i,3]<>c[j,3])
and (c[j,1]<t)and(c[j,2]<a) and(c[j,1]+c[i,1]>=t)and(c[j,2]+c[i,2]>=a)
then
begin
s[k]:=c[i,3]+c[j,3];
if k=1 then v:=s[k]
else prefer(s[k]);
inc(k);
end;
end;
end;
begin
assign(f,fin);reset(f);
assign(g,fout);rewrite(g);
read(f,t,a,n);
k:=1;
for i:= 1 to n do
for j:=1 to 3 do
read(f,p[i,j]);
try(p);
write(g,v);
close(f);
close(g);
end.