#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mir signed
#define pii pair<int,int>
#define tup tuple<int,int,int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl << '\n'
const int inf = 1e9;
int n,m;
vector<int> dx = {0,1,0,-1},dy = {1,0,-1,0};
void maxx(int &a,int b){
a = max(a,b);
}
bool valid(int i,int j){
if(i > 0 && j > 0 && j <= m && i <= n)return 1;
return 0;
}
void solve(){
cin >> n >> m;
vector<vector<int>> sira(n+1,vector<int>(m+1));
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)cin >> sira[i][j];
int cvb = 0;
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
for(int ii=1;ii<=n;++ii){
for(int jj=1;jj<=m;++jj){
maxx(cvb,abs(sira[i][j] - sira[ii][jj]) - 1 - abs(jj - j) - abs(ii - i));
}
}
}
}
maxx(cvb,0);
cout << cvb;
}
mir main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |