From 4b56a7a6b7a3539358567ffc94013113c68d2431 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 10 Nov 2021 17:21:51 +0800 Subject: [PATCH] =?UTF-8?q?1015.=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 https://www.acwing.com/problem/content/submission/code_detail/8745766/ --- AcWing/1015/1015.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 AcWing/1015/1015.cpp diff --git a/AcWing/1015/1015.cpp b/AcWing/1015/1015.cpp new file mode 100644 index 00000000..f9316ff6 --- /dev/null +++ b/AcWing/1015/1015.cpp @@ -0,0 +1,26 @@ +#include + +using namespace std; + +int t, r, c, w[1005][1005], f[1005][1005]; + +int main() { + cin >> t; + while (t--) { + memset(w, 0x00, sizeof(w)); + memset(f, 0x00, sizeof(f)); + cin >> r >> c; + for (int i = 1; i <= r; i++) { + for (int j = 1; j <= c; j++) { + cin >> w[i][j]; + } + } + for (int i = 1; i <= r; i++) { + for (int j = 1; j <= c; j++) { + f[i][j] = max(f[i][j - 1], f[i - 1][j]) + w[i][j]; + } + } + cout << f[r][c] << endl; + } + return 0; +}