#include<iostream> #include<cstring> #include<vector> using namespace std; vector<vector<int>> f; vector<vector<int>> w; int n,m,maxn = - 300; int main(){ cin >> n >> m; w.resize(n + 2); f.resize(n + 2); for(int i = 0;i <= n;i ++){ w[i].resize(m + 2,0); f[i].resize(m + 2,0); } for(int i = 1;i <= n;i ++) for(int j = 1;j <= m;j ++){ int a; cin >> a; w[i][j] = a; } for(int i = 1;i <= n;i ++) for(int j = 1;j <= m;j ++){ f[i][j] = f[i - 1][j] + f[i][j - 1] + w[i][j] - f[i - 1][j - 1]; maxn = max(maxn,f[i][j]); } cout << maxn; return 0; }
全部评论
(2) 回帖