답안 #98313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98313 2019-02-22T06:09:45 Z tmwilliamlin168 Maxcomp (info1cup18_maxcomp) C++14
100 / 100
241 ms 20476 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN=1e3;
int n, m, a[mxN][mxN], b1[mxN+1][mxN+1], b2[mxN+1][mxN+1], b3[mxN+1][mxN+1], b4[mxN+1][mxN+1], ans;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	memset(b1, 0xbf, sizeof(b1));
	memset(b2, 0xbf, sizeof(b2));
	memset(b3, 0xbf, sizeof(b3));
	memset(b4, 0xbf, sizeof(b4));
	for(int i=0; i<n; ++i) {
		for(int j=0; j<m; ++j) {
			cin >> a[i][j];
			b1[i+1][j+1]=max({b1[i][j+1], b1[i+1][j], -a[i][j]+i+j});
		}
		for(int j=m-1; ~j; --j)
			b2[i+1][j]=max({b2[i][j], b2[i+1][j+1], -a[i][j]+i-j});
	}
	for(int i=n-1; ~i; --i) {
		for(int j=0; j<m; ++j)
			b3[i][j+1]=max({b3[i+1][j+1], b3[i][j], -a[i][j]-i+j});
		for(int j=m-1; ~j; --j)
			b4[i][j]=max({b4[i+1][j], b4[i][j+1], -a[i][j]-i-j});
	}
	for(int i=0; i<n; ++i)
		for(int j=0; j<m; ++j)
			ans=max(a[i][j]+max({b1[i+1][j+1]-i-j, b2[i+1][j]-i+j, b3[i][j+1]+i-j, b4[i][j]+i+j}), ans);
	cout << ans-1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 16000 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 14 ms 16000 KB Output is correct
4 Correct 15 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 17 ms 16000 KB Output is correct
7 Correct 16 ms 16000 KB Output is correct
8 Correct 14 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 16000 KB Output is correct
2 Correct 15 ms 16000 KB Output is correct
3 Correct 15 ms 16000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 16000 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 14 ms 16000 KB Output is correct
4 Correct 15 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 17 ms 16000 KB Output is correct
7 Correct 16 ms 16000 KB Output is correct
8 Correct 14 ms 16000 KB Output is correct
9 Correct 15 ms 16220 KB Output is correct
10 Correct 16 ms 16304 KB Output is correct
11 Correct 15 ms 16256 KB Output is correct
12 Correct 16 ms 16252 KB Output is correct
13 Correct 14 ms 16256 KB Output is correct
14 Correct 15 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 16000 KB Output is correct
2 Correct 14 ms 16000 KB Output is correct
3 Correct 14 ms 16000 KB Output is correct
4 Correct 15 ms 16000 KB Output is correct
5 Correct 14 ms 16000 KB Output is correct
6 Correct 17 ms 16000 KB Output is correct
7 Correct 16 ms 16000 KB Output is correct
8 Correct 14 ms 16000 KB Output is correct
9 Correct 14 ms 16000 KB Output is correct
10 Correct 15 ms 16000 KB Output is correct
11 Correct 15 ms 16000 KB Output is correct
12 Correct 15 ms 16220 KB Output is correct
13 Correct 16 ms 16304 KB Output is correct
14 Correct 15 ms 16256 KB Output is correct
15 Correct 16 ms 16252 KB Output is correct
16 Correct 14 ms 16256 KB Output is correct
17 Correct 15 ms 16256 KB Output is correct
18 Correct 241 ms 20448 KB Output is correct
19 Correct 155 ms 20472 KB Output is correct
20 Correct 172 ms 20452 KB Output is correct
21 Correct 149 ms 20440 KB Output is correct
22 Correct 147 ms 20476 KB Output is correct
23 Correct 160 ms 20472 KB Output is correct
24 Correct 146 ms 20236 KB Output is correct