//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int N = 1e3;
int a[N * N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int ans = -1;
int n, m;
cin >> n >> m;
for (int i = 0; i < n * m; i++) {
cin >> a[i];
}
for (int i = 0; i < n * m; i++) {
for (int j = 0; j < n * m; j++) {
int x1 = i / m, y1 = i % m;
int x2 = j / m, y2 = j % m;
ans = max(ans, max(a[i], a[j]) - min(a[i], a[j]) - abs(x1 - x2) - abs(y1 - y2) - 1);
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
3 |
Correct |
11 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
63 ms |
376 KB |
Output is correct |
10 |
Correct |
59 ms |
376 KB |
Output is correct |
11 |
Correct |
58 ms |
380 KB |
Output is correct |
12 |
Correct |
59 ms |
376 KB |
Output is correct |
13 |
Correct |
57 ms |
376 KB |
Output is correct |
14 |
Correct |
64 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
12 ms |
376 KB |
Output is correct |
10 |
Correct |
12 ms |
376 KB |
Output is correct |
11 |
Correct |
11 ms |
380 KB |
Output is correct |
12 |
Correct |
63 ms |
376 KB |
Output is correct |
13 |
Correct |
59 ms |
376 KB |
Output is correct |
14 |
Correct |
58 ms |
380 KB |
Output is correct |
15 |
Correct |
59 ms |
376 KB |
Output is correct |
16 |
Correct |
57 ms |
376 KB |
Output is correct |
17 |
Correct |
64 ms |
448 KB |
Output is correct |
18 |
Execution timed out |
1032 ms |
12820 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |