0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 18:28:47 +00:00
Baoshuo Ren 2021-11-10 17:21:51 +08:00 committed by Baoshuo Ren
parent 05364a3261
commit 4b56a7a6b7
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

26
AcWing/1015/1015.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
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;
}