제출 #829331

#제출 시각아이디문제언어결과실행 시간메모리
829331khoquennguoiminhthuongMaxcomp (info1cup18_maxcomp)C++14
60 / 100
103 ms17060 KiB
#include <bits/stdc++.h> using namespace std; int m,n; int a[1005][1005]; int b[1005][1005]; int minn[1005][100]; int ans=-1e9; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>m>>n; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) cin>>a[i][j]; memset(minn,0x3f,sizeof(minn)); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) b[i][j]=a[i][j]-i-j; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) { minn[i][j]=min({minn[i-1][j],minn[i][j-1],b[i][j]}); ans=max(ans,a[i][j]-i-j-minn[i][j]-1); } memset(minn,0x3f,sizeof(minn)); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) b[i][j]=a[i][j]-i+j; for(int i=1; i<=m; i++) for(int j=n; j>=1; j--) { minn[i][j]=min({minn[i-1][j],minn[i][j+1],b[i][j]}); ans=max(ans,a[i][j]-i+j-minn[i][j]-1); } memset(minn,0x3f,sizeof(minn)); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) b[i][j]=-a[i][j]-i-j; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) { minn[i][j]=min({minn[i-1][j],minn[i][j-1],b[i][j]}); ans=max(ans,-a[i][j]-i-j-minn[i][j]-1); } memset(minn,0x3f,sizeof(minn)); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) b[i][j]=-a[i][j]-i+j; for(int i=1; i<=m; i++) for(int j=n; j>=1; j--) { minn[i][j]=min({minn[i-1][j],minn[i][j+1],b[i][j]}); ans=max(ans,-a[i][j]-i+j-minn[i][j]-1); } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...