#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <array>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <array>
#include <iomanip>
#include <fstream>
#include <cstdlib>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
vector<vector<int> >A(n);
vector<vector<int> >memo(n);
vector<int>a(m,0);
for(int i=0;i<n;i++){
A[i]=a;
memo[i]=a;
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>A[i][j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
memo[i][j]=A[i][j];
if(i!=0){
memo[i][j]=max(memo[i][j],memo[i-1][j]-1);
}
if(j!=0){
memo[i][j]=max(memo[i][j],memo[i][j-1]-1);
}
}
}
for(int i=n-1;i>=0;i--){
for(int j=m-1;j>=0;j--){
if(i!=n-1){
memo[i][j]=max(memo[i][j],memo[i+1][j]-1);
}
if(j!=m-1){
memo[i][j]=max(memo[i][j],memo[i][j+1]-1);
}
}
}
int ans=-1;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
ans=max(ans,memo[i][j]-A[i][j]-1);
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |