#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<vector<int>> a(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
int ans = -1e9;
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 temp = max(a[i][j], a[k][l]) - min(a[i][j], a[k][l]);
temp -= abs(i - k) + abs(j - l) + 1;
ans = max(ans, temp);
}
}
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
328 KB |
Output is correct |
2 |
Correct |
4 ms |
204 KB |
Output is correct |
3 |
Correct |
4 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
24 ms |
332 KB |
Output is correct |
10 |
Correct |
20 ms |
352 KB |
Output is correct |
11 |
Correct |
20 ms |
332 KB |
Output is correct |
12 |
Correct |
20 ms |
332 KB |
Output is correct |
13 |
Correct |
24 ms |
352 KB |
Output is correct |
14 |
Correct |
29 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
308 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
5 ms |
328 KB |
Output is correct |
10 |
Correct |
4 ms |
204 KB |
Output is correct |
11 |
Correct |
4 ms |
204 KB |
Output is correct |
12 |
Correct |
24 ms |
332 KB |
Output is correct |
13 |
Correct |
20 ms |
352 KB |
Output is correct |
14 |
Correct |
20 ms |
332 KB |
Output is correct |
15 |
Correct |
20 ms |
332 KB |
Output is correct |
16 |
Correct |
24 ms |
352 KB |
Output is correct |
17 |
Correct |
29 ms |
332 KB |
Output is correct |
18 |
Execution timed out |
1086 ms |
16616 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |