标签:

6 5 1 4 1 6 1 7 2 7 2 8 3 0
4
#include <stdio.h>
#include <string.h>
int dp[100010][13];
int MAX(int a,int b,int c){
int max;
max=a>b?a:b;
max=max>c?max:c;
return max;
}
int main()
{
int n;
int sec, locate;
int m;
while(scanf("%d",&n)){
if(n==0) break;
m=0;
memset(dp,0,sizeof(dp));
for(int i=0;i<n;i++){
scanf("%d%d",&locate,&sec);
dp[sec][locate+1]++;//locate+1,防止for循环中出现j-1=-1的情况
m=sec>m?sec:m;
}
for(int i=m;i>=0;i--){
for(int j=1;j<=11;j++){
dp[i][j]+=MAX(dp[i+1][j-1],dp[i+1][j],dp[i+1][j+1]);
}
}
printf("%d\n",dp[0][6]);//dp[0][5+1]开始位置
}
return 0;
}
标签:
原文地址:http://blog.csdn.net/mr_fan_123/article/details/51351924