답안 #96446

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

using namespace std;
typedef long long int lld;

lld abs(lld a){
	if(a>0)return a;
	return -a;
}
int main(){
	int n,m;
	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 B[n][m];
	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;
		}
	}
	lld minB[n][m];
	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);
		}
	}
	for(int i=0;i<n;i++){
		for(int j=m-1;j>-1;j--){
			B[i][j]=matrix[i][j]-i+j;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=m-1;j>-1;j--){
			minB[i][j]=B[i][j];
			if(i>0)minB[i][j]=min(minB[i][j],minB[i-1][j]);
			if(j<m-1)minB[i][j]=min(minB[i][j],minB[i][j+1]);
			ans=max(ans,B[i][j]-minB[i][j]-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -