标签:poj1163
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 36918 | Accepted: 22117 |
Description
7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1)
Input
Output
Sample Input
5 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5
Sample Output
30
#include <stdio.h>
int dp[102][102];
int max(int a, int b){ return a > b ? a : b; }
int main()
{
int n, i, j, ans;
scanf("%d", &n);
for(i = 1; i <= n; ++i){
for(j = 1; j <= i; ++j){
scanf("%d", &dp[i][j]);
dp[i][j] += max(dp[i-1][j], dp[i-1][j-1]);
}
}
ans = 0;
for(i = 1; i <= n; ++i)
if(dp[n][i] > ans) ans = dp[n][i];
printf("%d\n", ans);
return 0;
}标签:poj1163
原文地址:http://blog.csdn.net/chang_mu/article/details/37954893