闫式dp分析法
#include<iostream>
using namespace std;
const int N = 105;
int a[N][N], f[N][N];
int q, n, m;
int main()
{
cin >> T;
while(T-- ){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
}
}
// f[i][j]指的是到(i, j)的最大花生数
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
f[i][j] = max(f[i-1][j], f[i][j-1]) + a[i][j];
}
}
cout << f[n][m] << endl;
}
return 0;
}