bzoj 1207[HNOI 2004]モグラ狩り
1379 ワード
最大下降しないシーケンスのように水が落ち、走るのが超速い.
/**************************************************************
Problem: 1207
User: BPM136
Language: C++
Result: Accepted
Time:2724 ms
Memory:1428 kb
****************************************************************/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
inline LL read()
{
LL d=0,f=1;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}
return d*f;
}
#define N 1005
#define M 10005
int a[M][2],ti[M];
int f[M];
int n,m,ans=0;
int calc(int i,int j)
{
int x=a[i][0]-a[j][0];
int y=a[i][1]-a[j][1];
return abs(x)+abs(y);
}
int main()
{
n=read(),m=read();
fo(i,1,m)
{
int c=read(),x=read(),y=read();
ti[i]=c;
a[i][0]=x;
a[i][1]=y;
}
memset(f,0,sizeof(f));
fo(i,1,m)
{
f[i]=1;
fo(j,1,i-1)
if(ti[i]-ti[j]>=calc(i,j))
{
f[i]=max(f[i],f[j]+1);
}
ans=max(ans,f[i]);
}
cout<<ans<<endl;
return 0;
}