标签:
# include <iostream> # include <cstdio> # include <cstring> using namespace std; const int MAX = 100001; int dp[MAX][20]; int Max(int a, int b) { if(a > b) return a; return b; } int main () { int n; while (scanf("%d", &n) != EOF) { if(n == 0) break; memset(dp, 0, sizeof(dp)); int x, t, maxt = -1; for (int i = 1; i <= n; i++) { scanf("%d%d", &x, &t); if(maxt < t) maxt = t; dp[t][x + 1]++; } for (int i = maxt; i >= 0; i--) { for (int j = 1; j <= 11; j++) { dp[i][j] += Max(Max(dp[i + 1][j - 1], dp[i + 1][j + 1]), dp[i + 1][j]); } } printf("%d\n", dp[0][6]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/lyf-acm/p/5456480.html