hdu2881

/*
分析:
    dp。
    FUCK!,老纸跟multi的题杠上了!就算一星期也只能切一道题
我也跟你杠上了!!就算一道题要wa十几次或者几十次我也跟你杠
上了!!!尼玛天天折磨我很开心是不,啊?!次奥!!!老资
跟你杠上了!!!FUCK&&次奥!!!!!!

    垃圾代码垃圾方法,c++TLE,g++1000+ms
                                                        2013-04-11
*/







#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
using namespace std;
const int M=10005;

int n,m;
struct node{
	int t,x,y;
}E[M];
int dp[M];

int cmp(node n1,node n2){
	return n1.t<n2.t;
}
int main()
{
	int i,l;
	int temp;
	while(scanf("%d%d",&n,&m),n||m)
	{
		for(i=0;i<m;i++)	scanf("%d%d%d",&E[i].t,&E[i].x,&E[i].y);
		sort(E,E+m,cmp);

		int ans;
		ans=dp[0]=1;
		for(i=1;i<m;i++)
		{
			dp[i]=0;
			for(l=i-1;l>=0;l--)
			{
				temp=abs(E[i].x-E[l].x)+abs(E[i].y-E[l].y);
				if(temp>E[i].t-E[l].t)	continue;
				dp[i]=dp[i]>(dp[l]+1)?dp[i]:(dp[l]+1);
			}
			if(!dp[i])	dp[i]=1;
			if(dp[i]>ans)	ans=dp[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值