标签:
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): 34523 Accepted Submission(s): 11794
#include<stdio.h>
#include<string.h>
#define N 110000
#define max(a,b) (a>b?a:b)
#define max3(a,b,c) (max(a,max(b,c)))
int dp[N][20];
int main()
{
int n;
while(scanf("%d", &n), n)
{
int Max=0, time, p, i, j;
memset(dp, 0, sizeof(dp));
for(i=0; i<n; i++)
{
scanf("%d%d", &p, &time);
Max = max(Max, time);
dp[time][p+1]++;
}
for(i=Max-1; i>=0; i--)
for(j=1; j<=11; j++)
{
dp[i][j] += max3(dp[i+1][j-1], dp[i+1][j], dp[i+1][j+1]);
}
printf("%d\n", dp[0][6]);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/YY56/p/4959590.html