답안 #96448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96448 2019-02-09T13:38:37 Z KLPP Maxcomp (info1cup18_maxcomp) C++14
100 / 100
459 ms 32376 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int lld;
lld B[1000][1000];
lld minB[1000][1000];
int n,m;
lld abs(lld a){
	if(a>0)return a;
	return -a;
}
lld solve(){
	lld ans=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			minB[i][j]=B[i][j];
			if(i>0)minB[i][j]=min(minB[i][j],minB[i-1][j]);
			if(j>0)minB[i][j]=min(minB[i][j],minB[i][j-1]);
			ans=max(ans,B[i][j]-minB[i][j]-1);
		}
	}
	return ans;
}
int main(){
	cin>>n>>m;
	lld matrix[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>matrix[i][j];
		}
	}
	
	lld ans=-1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			B[i][j]=matrix[i][j]-i-j;
		}
	}
	ans=max(ans,solve());
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			B[i][j]=matrix[i][m-1-j]-i-j;
		}
	}
	ans=max(ans,solve());
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			B[i][j]=matrix[n-1-i][j]-i-j;
		}
	}
	ans=max(ans,solve());
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			B[i][j]=matrix[n-1-i][m-1-j]-i-j;
		}
	}
	ans=max(ans,solve());
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 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 376 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 376 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 888 KB Output is correct
11 Correct 3 ms 760 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Correct 4 ms 760 KB Output is correct
14 Correct 4 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 376 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 888 KB Output is correct
14 Correct 3 ms 760 KB Output is correct
15 Correct 3 ms 760 KB Output is correct
16 Correct 4 ms 760 KB Output is correct
17 Correct 4 ms 760 KB Output is correct
18 Correct 416 ms 24184 KB Output is correct
19 Correct 401 ms 32332 KB Output is correct
20 Correct 379 ms 31608 KB Output is correct
21 Correct 401 ms 32276 KB Output is correct
22 Correct 408 ms 32248 KB Output is correct
23 Correct 459 ms 32376 KB Output is correct
24 Correct 424 ms 32064 KB Output is correct