This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(), x.end()
const int N = 1001;
using namespace std;
ll n, m, k, a, b, p[N][N];
signed main (){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++){
for (int y = 1; y <= m; y++){
cin >> p[i][y];
a = max (a, p[i][y]);
}
}
b = -1;
for (int i = 1; i <= n; i++){
for (int y = 1; y <= m; y++){
if (p[i][y] == a){
for (int j = 1; j <= n; j++){
for (int k = 1; k <= m; k++){
b = max (p[i][y] - p[j][k] - (abs (i - j) + abs (y - k) + 1), b);
// cout << p[i][y] - p[j][k] - (abs (i - j) + abs (y - k) + 1) << ' ' << j << ' ' << k << ' ' << i << ' ' << y << '\n';
}
}
}
}
}
cout << b;
}
# | 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... |