'commit'
This commit is contained in:
32
TangDou/CSP-J/AcWingTraining/T6/126_ErWei.cpp
Normal file
32
TangDou/CSP-J/AcWingTraining/T6/126_ErWei.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int INF = 0x3f3f3f3f;
|
||||
const int N = 110;
|
||||
int g[N][N];
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j <= n; j++) {
|
||||
cin >> g[i][j];
|
||||
// 累加出并记录同一列的前缀和
|
||||
g[i][j] += g[i - 1][j];
|
||||
}
|
||||
|
||||
int res = -INF;
|
||||
|
||||
// 枚举边界1,2
|
||||
for (int i = 1; i <= n; i++) // 起始行
|
||||
for (int j = i; j <= n; j++) { // 终止行
|
||||
// 枚举边界p
|
||||
int last = 0;
|
||||
for (int k = 1; k <= n; k++) {
|
||||
last = max(last, 0) + g[j][k] - g[i - 1][k];
|
||||
res = max(res, last);
|
||||
}
|
||||
}
|
||||
|
||||
cout << res << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user