#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int n,m;
const int inf=1e9+10;
int a[1009][1009];
int b[1009][1009];
int main()
{
fast;
cin>>n>>m;
for(int i=1;i<n+1;i++)
{
for(int j=1;j<m+1;j++)
{
cin>>a[i][j];
}
}
int re=0;
for(int i=1;i<n+1;i++)
{
int mx=0;
for(int j=1;j<m+1;j++)
{
b[i][j]=max(b[i-1][j]-1,a[i][j]);
}
for(int j=1;j<m+1;j++)
{
re=max(re,mx-a[i][j]-1);
mx=max(mx,b[i][j]);
mx--;
}
}
memset(b,0,sizeof b);
for(int j=1;j<m+1;j++)
b[0][j]=inf;
for(int i=1;i<n+1;i++)
{
int mx=inf;
for(int j=1;j<m+1;j++)
{
b[i][j]=min(b[i-1][j]+1,a[i][j]);
}
for(int j=1;j<m+1;j++)
{
//cout<<mx<<" ";
re=max(re,a[i][j]-1-mx);
mx=min(mx,b[i][j]);
mx++;
}
}
cout<<re;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4472 KB |
Output is correct |
2 |
Correct |
5 ms |
4344 KB |
Output is correct |
3 |
Incorrect |
5 ms |
4344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4344 KB |
Output is correct |
2 |
Correct |
5 ms |
4348 KB |
Output is correct |
3 |
Correct |
5 ms |
4348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4472 KB |
Output is correct |
2 |
Correct |
5 ms |
4344 KB |
Output is correct |
3 |
Incorrect |
5 ms |
4344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
4472 KB |
Output is correct |
2 |
Correct |
5 ms |
4344 KB |
Output is correct |
3 |
Incorrect |
5 ms |
4344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |