#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int inf = 2e9;
int n, m;
int a[maxn][maxn];
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
cin >> a[i][j];
}
}
int ans = -inf;
for (int x1 = 1; x1 <= n; ++x1)
{
for (int y1 = 1; y1 <= m; ++y1)
{
for (int x2 = 1; x2 <= n; ++x2)
{
for (int y2 = 1; y2 <= m; ++y2)
{
if (x1 != x2 || y1 != y2)
{
ans = max(ans, abs(a[x1][y1] - a[x2][y2]) - (abs(x1 - x2) + abs(y1 - y2)));
}
}
}
}
}
cout << ans - 1 << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
472 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
472 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
12 ms |
2652 KB |
Output is correct |
10 |
Correct |
12 ms |
2724 KB |
Output is correct |
11 |
Correct |
12 ms |
2652 KB |
Output is correct |
12 |
Correct |
16 ms |
2648 KB |
Output is correct |
13 |
Correct |
13 ms |
2720 KB |
Output is correct |
14 |
Correct |
13 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
472 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
12 ms |
2652 KB |
Output is correct |
13 |
Correct |
12 ms |
2724 KB |
Output is correct |
14 |
Correct |
12 ms |
2652 KB |
Output is correct |
15 |
Correct |
16 ms |
2648 KB |
Output is correct |
16 |
Correct |
13 ms |
2720 KB |
Output is correct |
17 |
Correct |
13 ms |
2652 KB |
Output is correct |
18 |
Execution timed out |
1091 ms |
12936 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |