제출 #169327

#제출 시각아이디문제언어결과실행 시간메모리
169327Rouge_HugoMaxcomp (info1cup18_maxcomp)C++14
100 / 100
155 ms25068 KiB
#include <bits/stdc++.h> #define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long using namespace std; int n,m; const ll inf=1e11+10; ll a[1009][1009]; ll b[1009][1009]; int main() { fast; cin>>n>>m; for(int i=1;i<n+1;i++) { for(int j=1;j<m+1;j++) { cin>>a[i][j]; } } ll re=-1; for(int i=1;i<n+1;i++) { ll mx=0; for(int j=1;j<m+1;j++) { b[i][j]=max(b[i-1][j]-1,a[i][j]); } for(int j=1;j<m+1;j++) { mx=max(mx,b[i][j]); re=max(re,mx-a[i][j]-1); mx--; } mx=0; for(int j=m;j>0;j--) { mx=max(mx,b[i][j]); re=max(re,mx-a[i][j]-1); mx--; } } memset(b,0,sizeof b); for(int j=1;j<m+1;j++) b[0][j]=inf; for(int i=1;i<n+1;i++) { ll mx=inf; for(int j=1;j<m+1;j++) { b[i][j]=min(b[i-1][j]+1,a[i][j]); } for(int j=1;j<m+1;j++) { mx=min(mx,b[i][j]); re=max(re,a[i][j]-1-mx); mx++; } mx=inf; for(int j=m;j>0;j--) { mx=min(mx,b[i][j]); re=max(re,a[i][j]-1-mx); mx++; } } cout<<re; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...