답안 #127297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127297 2019-07-09T07:56:22 Z E869120 Maxcomp (info1cup18_maxcomp) C++14
100 / 100
188 ms 17100 KB
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <cassert>
using namespace std;
#pragma warning (disable: 4996)

int N, M, A[1009][1009], dist[1009][1009];

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) { scanf("%d", &A[i][j]); dist[i][j] = A[i][j] - 1; }
	}
	
	for (int i = 1; i <= N; i++) {
		for (int j = 2; j <= M; j++) dist[i][j] = max(dist[i][j], dist[i][j - 1] - 1);
		for (int j = M - 1; j >= 1; j--) dist[i][j] = max(dist[i][j], dist[i][j + 1] - 1);
	}
	for (int i = 1; i <= M; i++) {
		for (int j = 2; j <= N; j++) dist[j][i] = max(dist[j][i], dist[j - 1][i] - 1);
		for (int j = N - 1; j >= 1; j--) dist[j][i] = max(dist[j][i], dist[j + 1][i] - 1);
	}

	int maxn = -1;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) maxn = max(maxn, dist[i][j] - A[i][j]);
	}
	cout << maxn << endl;
	return 0;
}

Compilation message

maxcomp.cpp:7:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
 
maxcomp.cpp: In function 'int main()':
maxcomp.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &M);
  ~~~~~^~~~~~~~~~~~~~~~
maxcomp.cpp:14:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for (int j = 1; j <= M; j++) { scanf("%d", &A[i][j]); dist[i][j] = A[i][j] - 1; }
                                  ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 368 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 368 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 3 ms 760 KB Output is correct
11 Correct 3 ms 760 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 368 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 760 KB Output is correct
16 Correct 3 ms 760 KB Output is correct
17 Correct 3 ms 760 KB Output is correct
18 Correct 187 ms 8612 KB Output is correct
19 Correct 188 ms 16900 KB Output is correct
20 Correct 177 ms 16444 KB Output is correct
21 Correct 186 ms 16760 KB Output is correct
22 Correct 186 ms 16760 KB Output is correct
23 Correct 187 ms 16776 KB Output is correct
24 Correct 150 ms 17100 KB Output is correct