Submission #882238

# Submission time Handle Problem Language Result Execution time Memory
882238 2023-12-02T20:29:06 Z rainboy Maxcomp (info1cup18_maxcomp) C
100 / 100
140 ms 17236 KB
#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

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
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2480 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2552 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2480 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 140 ms 16720 KB Output is correct
19 Correct 97 ms 16720 KB Output is correct
20 Correct 91 ms 16392 KB Output is correct
21 Correct 113 ms 16712 KB Output is correct
22 Correct 95 ms 16528 KB Output is correct
23 Correct 95 ms 16740 KB Output is correct
24 Correct 110 ms 17236 KB Output is correct