Bzoj 1207 打鼹鼠
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1207
一开始被这个二维平面吓到了。。没有想到可以用 f[i]表示打到第i只鼹鼠时最多打了几只
f[i]=max(f[i],f[j]+1),其中由j可以到i,即 0<=time[i]-time[j];
Code://欢迎大神指点
var
n,m,i,j,ans:longint;
f,x,y,time:array[0..10010]of longint;
function max(i,j:longint):longint;
begin
if i>=j then exit(i);exit(j)
end;
procedure init;
var i:longint;
begin
readln(n,m);
fillchar(f,sizeof(f),0);
for i:=1 to m do begin
f[i]:=1;
readln(time[i],x[i],y[i]);
end;
ans:=1;
end;
begin
init;
for i:=2 to m do
for j:=1 to i-1 do
if(f[j]+1>f[i])and(abs(x[i]-x[j])+abs(y[i]-y[j])<=time[i]-time[j])then
f[i]:=f[j]+1;
for i:=1 to m do ans:=max(ans,f[i]);
writeln(ans)
end.