bzoj 1207: [HNOI2004]打鼹鼠 (dp)

var
  n,m,i,j,ans:longint;
  x,y,time,f:array[0..10010]of longint;
 
 
begin
  readln(n,m);
  for i:=1 to m do
 
    readln(time[i],x[i],y[i]);
  ans:=1;
  for i:=1 to m do begin
    f[i]:=1;
    for j:=1 to i-1 do
      if (time[i]-time[j]>=abs(x[i]-x[j])+abs(y[i]-y[j])) and (f[i]<f[j]+1) then begin
        f[i]:=f[j]+1;
        if f[i]>ans then ans:=f[i];
    end;
  end;
  writeln(ans);
end.
View Code

 

posted @ 2015-03-22 22:11  Macaulish  阅读(358)  评论(0编辑  收藏  举报