#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define ll long long
#define pii pair<int, int>
#define maxn 1005
using namespace std;
int a[maxn][maxn], mi[maxn][maxn], ma[maxn][maxn];
int n, m;
inline int ab(int a) {
return a > 0 ? a : -a;
}
/*
struct segtree {
int seg[4 * maxn];
void init(int cur, int l, int r, bool oper) {
if (r <= l) return;
if (r - l == 1) {
seg[cur] = a[0][l];
return;
}
int mid = (l + r) / 2;
init(cur * 2, l, mid, oper);
init(cur * 2 + 1, mid, r, oper);
if (oper) seg[cur] = max(seg[cur * 2], seg[cur * 2 + 1]);
else seg[cur] = min(seg[cur * 2], seg[cur * 2 + 1]);
}
} s1, s2;
*/
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> m;
for (int i = 0;i < n;i++) {
for (int j = 0;j < m;j++) cin >> a[i][j];
}
int ans = 0;
for (int x1 = 0;x1 < n;x1++) {
for (int x2 = 0;x2 < n;x2++) {
for (int y1 = 0;y1 < m;y1++) {
for (int y2 = 0;y2 < m;y2++) {
int dist = ab(x2 - x1) + ab(y2 - y1) + 1;
//cout << x1 << " " << y1 << " " << x2 << " " << y2 << ' ' << dist << endl;
ans = max(ans, max(a[x1][y1], a[x2][y2]) - min(a[x1][y1], a[x2][y2]) - dist);
}
}
}
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |