0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 16:18:46 +00:00

1284. 摘花生

http://ybt.ssoier.cn:8088/statusx.php?runidx=15574717
This commit is contained in:
Baoshuo Ren 2022-04-02 21:30:29 +08:00
parent 7e859ac796
commit 2b4c824a0e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

36
ybt/1284/1284.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <cstring>
#include <iostream>
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;
}