This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define N 1000
#define M 1000
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int aa[N][M], bb[N][M];
int n, m, i, j, ans;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
for (j = 0; j < m; j++) {
scanf("%d", &aa[i][j]);
bb[i][j] = aa[i][j];
}
for (i = 0; i < n; i++) {
for (j = 1; j < m; j++)
bb[i][j] = min(bb[i][j], bb[i][j - 1] + 1);
for (j = m - 2; j >= 0; j--)
bb[i][j] = min(bb[i][j], bb[i][j + 1] + 1);
}
for (j = 0; j < m; j++) {
for (i = 1; i < n; i++)
bb[i][j] = min(bb[i][j], bb[i - 1][j] + 1);
for (i = n - 2; i >= 0; i--)
bb[i][j] = min(bb[i][j], bb[i + 1][j] + 1);
}
ans = -1;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
ans = max(ans, aa[i][j] - bb[i][j] - 1);
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
maxcomp.c: In function 'main':
maxcomp.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
maxcomp.c:16:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%d", &aa[i][j]);
| ^~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |