mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 12:18:50 +00:00
1015. 摘花生
https://www.acwing.com/problem/content/submission/code_detail/8745766/
This commit is contained in:
parent
05364a3261
commit
4b56a7a6b7
26
AcWing/1015/1015.cpp
Normal file
26
AcWing/1015/1015.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user