이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int n, m, ans = -2;
int ar[3005][3005];
signed 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 >> ar[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
for (int k = 0; k < n; k++) {
for (int l = 0; l < m; l++) {
int tmp = max(ar[i][j], ar[k][l]) - min(ar[i][j], ar[k][l]);
if (i == k && j == l) {
tmp--;
} else if (i == k) {
tmp -= abs(j - l) + 1;
} else if (j == l) {
tmp -= abs(i - k) + 1;
} else {
tmp -= abs(i - k) + abs(j - l) + 1;
}
ans = max(ans, tmp);
}
}
}
}
cout << ans << '\n';
return 0;
}
# | 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... |