首页 > 其他 > 详细

bzoj1207 [HNOI2004]打鼹鼠

时间:2016-01-22 17:40:25      阅读:145      评论:0      收藏:0      [点我收藏+]

题目链接

一道比较简单的DP

距离够则转移

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<string>
 5 #include<cstring>
 6 #include<cmath>
 7 #include<algorithm>
 8 #include<ctime>
 9 #include<queue>
10 #include<stack>
11 #include<map>
12 #include<set>
13 using namespace std;
14 int n,m,t[10010],x[10010],y[10010],hh[10010];
15 int jue(const int &x)
16 {
17     return x<0?-x:x;
18 }
19 int dis(const int &q,const int &w,const int &e,const int &r)
20 {
21     return jue(q-e)+jue(w-r);
22 }
23 int main()
24 {
25     scanf("%d%d",&n,&m);
26     for(int i=1;i<=m;i++)
27     {
28         scanf("%d%d%d",&t[i],&x[i],&y[i]);
29         hh[i]=1;
30     }
31     for(int i=1;i<=m;i++)
32         for(int j=1;j<i;j++)
33             if(t[i]-t[j]>=dis(x[i],y[i],x[j],y[j]))hh[i]=max(hh[i],hh[j]+1);
34     int ans=0;
35     for(int i=1;i<=m;i++)ans=max(ans,hh[i]);
36     printf("%d",ans);
37     return 0;
38 }

 

bzoj1207 [HNOI2004]打鼹鼠

原文:http://www.cnblogs.com/HugeGun/p/5151412.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!