#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 1005;
const int dx[] = {0, 0, -1, +1}, dy[] = {-1, +1, 0, 0};
int n, m;
int a[N][N];
long long dp[N][N];
long long res = -INF;
vector < pair<int,int> > vals;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> a[i][j];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
for (int k = 1; k <= n; ++k) {
for (int l = 1; l <= m; ++l) {
int diff = abs(i - k) + abs(j - l) + 1;
res = max(res, (long long)a[i][j] - a[k][l] - diff);
}
}
}
}
cout << res << endl;
}
# |
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 |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
736 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 |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
17 ms |
744 KB |
Output is correct |
10 |
Correct |
18 ms |
744 KB |
Output is correct |
11 |
Correct |
18 ms |
872 KB |
Output is correct |
12 |
Correct |
18 ms |
928 KB |
Output is correct |
13 |
Correct |
19 ms |
928 KB |
Output is correct |
14 |
Correct |
17 ms |
928 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 |
560 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
2 ms |
640 KB |
Output is correct |
8 |
Correct |
2 ms |
640 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
5 ms |
640 KB |
Output is correct |
11 |
Correct |
5 ms |
736 KB |
Output is correct |
12 |
Correct |
17 ms |
744 KB |
Output is correct |
13 |
Correct |
18 ms |
744 KB |
Output is correct |
14 |
Correct |
18 ms |
872 KB |
Output is correct |
15 |
Correct |
18 ms |
928 KB |
Output is correct |
16 |
Correct |
19 ms |
928 KB |
Output is correct |
17 |
Correct |
17 ms |
928 KB |
Output is correct |
18 |
Execution timed out |
1069 ms |
4628 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |