zxfbit @ 2024-02-16 20:07:29
#include<iostream>
using namespace std;
int a[1010][1010],s[1010][1010],n,m;
int maxx=INT_MIN;
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
cin>>a[i][j];
s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
}
int x1,x2,y1,y2;
for(int x1=1;x1<=n;x1++)
for(int y1=1;y1<=n;y1++)
for(int x2=x1;x2<=n;x2++)
for(int y2=y1;y2<=n;y2++)
{
maxx=max(maxx,s[x2][y2]-s[x2][y1-1]-s[x1-1][y2]+s[x1-1][y1-1]);
}
cout<<maxx<<endl;
return 0;
}
by zxfbit @ 2024-02-16 20:08:11
为啥编译失败啊
by HEROBRINEH @ 2024-02-16 20:13:25
#include <climits>
你少了这个东西,加到第2行,加了之后AC(亲测)
by HEROBRINEH @ 2024-02-16 20:14:04
给个关注呗
by QWQ_123 @ 2024-02-16 20:14:47
@zxfbit
/tmp/compiler_e52tvfsd/src:6:10: 错误:‘INT_MIN’在此作用域中尚未声明
6 | int maxx=INT_MIN;
| ^~~~~~~
/tmp/compiler_e52tvfsd/src:2:1: 附注:‘INT_MIN’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
1 | #include<iostream>
+++ |+#include <climits>
2 |
by QWQ_123 @ 2024-02-16 20:15:46
@zxfbit 显然的 INT_MIN
不在 iostream
里,然后你可以直接用 bits/stdc++.h
,当然也可以如同编译信息里面说的加上 climits
。
by Lele_Programmer @ 2024-02-16 20:22:37
直接用 -0x7fffffff 不好吗
by zxfbit @ 2024-02-16 20:25:51
感谢,已关注
by zxfbit @ 2024-02-16 20:26:15
@QWQ_123 感谢,关注了