标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 33362 Accepted Submission(s): 11410
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<algorithm> #define N 100010 using namespace std; int dp[N][20];//dp[i][j]表示第i秒在位置j处能接的馅饼数 int main() { int n, x, t, T, i, j; while(scanf("%d", &n), n) { memset(dp, 0, sizeof(dp)); T = 0; while(n--) { scanf("%d%d", &x, &t); dp[t][x + 1]++; T = max(T, t);//找出最长能够接馅饼的时间 } for(i = T - 1 ; i >= 0 ; i--) { for(j = 11 ; j >= 0 ; j--) dp[i][j] += max(max(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/qq2424260747/p/4779873.html