标签:enter 分析 tar 状态 最大值 pac title 就是 ref
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1176
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 60927 Accepted Submission(s): 21380

#include<bits/stdc++.h>
using namespace std;
#define max_v 100005
int dp[max_v][20];
int main()
{
int n;
while(~scanf("%d",&n))
{
if(n==0)
break;
memset(dp,0,sizeof(dp));
int t=-1;
for(int i=0;i<n;i++)
{
int x,y;
scanf("%d %d",&x,&y);
dp[y][x]++;
if(y>t)
t=y;
}
for(int i=t-1;i>=0;i--)
{
for(int j=10;j>=0;j--)
{
dp[i][j]=max(dp[i+1][j],max(dp[i+1][j-1],dp[i+1][j+1]))+dp[i][j];
}
}
printf("%d\n",dp[0][5]);
}
return 0;
}
HDU 1176(类似数字三角形的题,很经典,值得仔细理解的dp思维)
标签:enter 分析 tar 状态 最大值 pac title 就是 ref
原文地址:https://www.cnblogs.com/yinbiao/p/9157535.html