#include <iostream> #include <stdio.h> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int maxn = 1001; int D[maxn][maxn]; int DP[maxn][maxn]; int main() { int n, quan; cin >> quan; while (quan--) { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) cin >> D[i][j]; for (int i = 1; i <= n; i++) DP[n][i] = D[n][i]; for(int i=n-1;i>=1;i--) for (int j = 1; j <= i; j++) { DP[i][j] = max(DP[i + 1][j], DP[i + 1][j + 1]) + D[i][j]; } cout << DP[1][1] << endl; } return 0; }
0.0分
0 人评分
C语言训练-求1+2!+3!+...+N!的和 (C语言代码)浏览:2468 |
妹子杀手的故事 (C语言代码)浏览:691 |
C二级辅导-统计字符 (C语言代码)浏览:506 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:465 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1176 |
简单的for循环浏览:1410 |
WU-链表数据求和操作 (C++代码)浏览:1316 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:702 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:327 |
数字游戏 (C++代码)浏览:1185 |