#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 600005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sz(s) (int)s.size()
#define pii pair<int,int>
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll T, n, a[2000][2000], t, m, answer = -1, vis[2000][2000], dp[2000][2000];
vector <pair<int,int>> path, ans;
int main () {
ios::sync_with_stdio(0);cin.tie(0);
cin >> n >> m;
bool tr = 0;
for(int i = 1;i <= n;i++) {
for(int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j= 1;j<=m;j++) {
for(int k = 1; k <= n; k++) {
for(int l= 1;l<=m;l++) {
if(i == k && j == l) continue;
answer = max(answer, abs(a[i][j] - a[k][l]) - abs(i - k) - abs(j - l) - 1);
}
}
}
}
cout << answer << '\n';
}
# | 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... |