#include<bits/stdc++.h>
using namespace std;
int a[2005][2005];
long long res, ans = -1e18;
int main(){
int n;
cin>>n;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) cin>>a[i][j];
}
for(int i = 1; i <= n; i++) {
res = 0;
for(int j = 1; j <= n; j++)
res += a[i][j];
ans = max(ans, res);
}
for(int i = 1; i <= n-1; i++) {
res = 0;
for(int j = 1; j <= n; j++)
res += a[j][i];
ans = max(ans, res);
}
for(int i = 1-n; i <= n-1; i++) {
res = 0;
for(int j = 1; j <= n; j++)
if(j-i>=1 && i-j <= n) res += a[j][j-i];
ans = max(ans, res);
}for(int i = 2; i <= n+n; i++) {
res = 0;
for(int j = 1; j <= n; j++)
if(i-j>=1 && i-j <= n) res += a[j][i-j];
ans = max(ans, res);
}
cout << ans << '\n';
}
12-16
02-14
460
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-12
319
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-08