比赛 |
2008haoi模拟训练3 |
评测结果 |
AWAAAWWAAA |
题目名称 |
潜水员的问题 |
最终得分 |
70 |
用户昵称 |
梦里醉逍遥 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-04-24 08:58:33 |
显示代码纯文本
program ple;
const
fi='ple.in'; fo='ple.out';
maxt=42; maxa=158;
type
arr=array[0..100,0..200] of longint;
bag=array[1..1000] of longint;
var
fin,fout:text;
n,t,a,min:longint;
f:arr; ti,ai,wi:bag;
procedure init;
var
i:longint;
begin
assign(fin,fi); reset(fin);
readln(fin,t,a); readln(fin,n);
for i:=1 to n do
readln(fin,ti[i],ai[i],wi[i]);
close(fin);
end;
procedure main;
var
i,j,k:longint;
begin
min:=maxlongint;
for i:=1 to n do
for j:=maxt downto ti[i] do
for k:=maxa downto ai[i] do
if ((j-ti[i]=0) and (k-ai[i]=0)) or (f[j-ti[i],k-ai[i]]<>0) then
if (f[j,k]=0) or (f[j,k]>f[j-ti[i],k-ai[i]]+wi[i]) then
f[j,k]:=f[j-ti[i],k-ai[i]]+wi[i];
for j:=t to maxt do
for k:=a to maxa do
if (f[j,k]<min) and (f[j,k]<>0) then
min:=f[j,k];
end;
procedure print;
begin
assign(fout,fo); rewrite(fout);
writeln(fout,min); close(fout);
end;
begin
init;
main;
print;
end.