比赛 2008haoi模拟训练3 评测结果 AAAAAAAAAA
题目名称 潜水员的问题 最终得分 100
用户昵称 francis 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-04-24 09:33:37
显示代码纯文本
program ple;
const
max=900000;
var
a:array[0..1000,1..21,1..79]of longint;
b:array[1..1000,1..3]of longint;
min,all,x,y,k,n,i,j,t,a1,ti,ai,wi:longint;
f1,f2:text;

procedure init;
begin
assign(f1,'ple.in');
assign(f2,'ple.out');
reset(f1); rewrite(f2);
read(f1,t,a1,n);
for i:=1 to n do
for j:=1 to 3 do
read(f1,b[i,j]);
for i:=1 to t do
for j:=1 to a1 do
a[0,i,j]:=max;
end;

begin
init;
for k:=1 to  n do
for i:=1 to t do
for j:=1 to a1 do
begin
x:=i-b[k,1]; y:=j-b[k,2];
if (x<=0)and(y<=0) then all:=b[k,3];
if (x<=0)and(y>0)  then all:=a[k-1,1,y]+b[k,3];
if (x>0)and(y<=0)  then all:=a[k-1,x,1]+b[k,3];
if (x>0)and(y>0)   then all:=a[k-1,x,y]+b[k,3];
if all<a[k-1,i,j]  then a[k,i,j]:=all
                   else a[k,i,j]:=a[k-1,i,j];
end;
min:=a[n,t,a1];
write(f2,min);
close(f1); close(f2);
end.