标签:ima ret gif img stream scan sam fine others
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 43123 Accepted Submission(s): 25508
//#define MY_DEBUG #include <iostream> #include <cstdio> using namespace std; const int MAXN = 128; int dp[MAXN][MAXN]; int a[MAXN][MAXN]; int main() { #ifdef MY_DEBUG freopen("./in.txt", "r", stdin); //freopen("./out.txt", "w", stdout); #endif // MY_DEBUG int c, n; int i, j; scanf("%d", &c); while (c--) { scanf("%d", &n); for (i = 0; i < n; ++i) { for (j = 0; j <= i; ++j) { scanf("%d", &a[i][j]); } } for (j = 0; j < n + 1; ++j) { dp[n][j] = 0; } for (i = n - 1; i >= 0; --i) { for (j = 0; j <= i; ++j) { dp[i][j] = max(dp[i + 1][j], dp[i + 1][j + 1]) + a[i][j]; } } printf("%d\n", dp[0][0]); } return 0; }
标签:ima ret gif img stream scan sam fine others
原文地址:http://www.cnblogs.com/bofengyu/p/6730639.html