1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #include<iostream> #include<cstdio> #include<cstdlib> #define N 10005 using namespace std; int n,m,ans; int f[N],t[N],x[N],y[N],maxx[N]; int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=m;i++) scanf("%d%d%d",&t[i],&x[i],&y[i]); f[1]=1; maxx[1]=1; for(int i=2;i<=m;i++){ f[i]=1; for(int j=i-1;j;j--){ if (maxx[j]+1<=f[i]) break; if (f[j]+1>f[i]&&abs(x[i]-x[j])+abs(y[i]-y[j])<=t[i]-t[j]) f[i]=f[j]+1; } maxx[i]=max(f[i],maxx[i-1]); ans=max(ans,f[i]); } printf("%d",ans); return 0; }
|