#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,m,a,b,ans = -INT_MAX;
cin >> n >> m;
int haha[n][m];
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
cin >> haha[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 y = 0; y < m; y++) {
a = haha[i][j];
b = haha[k][y];
if(a < b) {
swap(a,b);
}
ans = max(ans,a-b-abs(i-k)-abs(j-y)-1);
}
}
}
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
324 KB |
Output is correct |
2 |
Correct |
4 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
21 ms |
352 KB |
Output is correct |
10 |
Correct |
15 ms |
332 KB |
Output is correct |
11 |
Correct |
15 ms |
348 KB |
Output is correct |
12 |
Correct |
15 ms |
348 KB |
Output is correct |
13 |
Correct |
15 ms |
352 KB |
Output is correct |
14 |
Correct |
24 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
324 KB |
Output is correct |
10 |
Correct |
4 ms |
332 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
21 ms |
352 KB |
Output is correct |
13 |
Correct |
15 ms |
332 KB |
Output is correct |
14 |
Correct |
15 ms |
348 KB |
Output is correct |
15 |
Correct |
15 ms |
348 KB |
Output is correct |
16 |
Correct |
15 ms |
352 KB |
Output is correct |
17 |
Correct |
24 ms |
340 KB |
Output is correct |
18 |
Execution timed out |
1061 ms |
12648 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |