From 2b4c824a0e13fa9d9a3adf81330a7da9775d29f7 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 2 Apr 2022 21:30:29 +0800 Subject: [PATCH] =?UTF-8?q?1284.=20=E6=91=98=E8=8A=B1=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://ybt.ssoier.cn:8088/statusx.php?runidx=15574717 --- ybt/1284/1284.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ybt/1284/1284.cpp diff --git a/ybt/1284/1284.cpp b/ybt/1284/1284.cpp new file mode 100644 index 00000000..d583c309 --- /dev/null +++ b/ybt/1284/1284.cpp @@ -0,0 +1,36 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 105; + +int t, n, m, g[N][N], f[N][N]; + +int main() { + std::ios::sync_with_stdio(false); + + cin >> t; + while (t--) { + memset(f, 0x00, sizeof(f)); + + cin >> n >> m; + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + cin >> g[i][j]; + } + } + + for (int i = 1; i <= n; i++) { + for (int j = 1; j <= m; j++) { + f[i][j] = std::max(f[i - 1][j], f[i][j - 1]) + g[i][j]; + } + } + + cout << f[n][m] << endl; + } + + return 0; +}