This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 55;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m;
int a[MAXN][MAXN];
void read()
{
cin >> n >> m;
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
cin >> a[i][j];
}
}
void solve()
{
int ans = 0;
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
{
for (int x = 1; x <= n; ++ x)
{
for (int y = 1; y <= m; ++ y)
{
int maxx = max(a[i][j], a[x][y]);
int minn = min(a[i][j], a[x][y]);
int s = abs(x - i) + abs(y - j) + 1;
///cout << i << " " << j << ", " << x << ", " << y << " -> " << maxx - minn - s << endl;
ans = max(ans, maxx - minn - s);
}
}
}
}
cout << ans << endl;
}
int main()
{
speed();
read();
solve();
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... |