标签:
6 5 1 4 1 6 1 7 2 7 2 8 3 0
4
#include <stdio.h> #include <string.h> int a[100005][11]; int max(int a,int b) { if (a>b) return a; else return b; } int main() { int n,i,j,x,t,maxi; while (scanf("%d",&n)!=EOF&&n) { memset(a,0,sizeof(a)); maxi=0; for (i=0;i<n;i++) { scanf("%d%d",&x,&t); a[t][x]++; if (t>maxi) maxi=t; } for (i=maxi-1;i>=0;i--) { for (j=0;j<=10;j++) { if (j==0) a[i][j]+=max(a[i+1][j],a[i+1][j+1]); else if (j==10) a[i][j]+=max(a[i+1][j-1],a[i+1][j]); else a[i][j]+=max(max(a[i+1][j-1],a[i+1][j]),a[i+1][j+1]); } } printf("%d\n",a[0][5]); } return 0; }
标签:
原文地址:http://blog.csdn.net/u013224148/article/details/43670097