Submission #882238

#TimeUsernameProblemLanguageResultExecution timeMemory
882238rainboyMaxcomp (info1cup18_maxcomp)C11
100 / 100
140 ms17236 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...