Submission #95346

#TimeUsernameProblemLanguageResultExecution timeMemory
95346dalgerokMaxcomp (info1cup18_maxcomp)C++14
100 / 100
141 ms28580 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int n, m, a[N][N], dp1[N][N], dp2[N][N], dp3[N][N], dp4[N][N]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin >> a[i][j]; dp1[i][j] = max({dp1[i - 1][j], dp1[i][j - 1], a[i][j]}) - 1; } for(int j = m; j >= 1; j--){ dp2[i][j] = max({dp2[i - 1][j], dp2[i][j + 1], a[i][j]}) - 1; } } for(int i = n; i >= 1; i--){ for(int j = 1; j <= m; j++){ dp3[i][j] = max({dp3[i + 1][j], dp3[i][j - 1], a[i][j]}) - 1; } for(int j = m; j >= 1; j--){ dp4[i][j] = max({dp4[i + 1][j], dp4[i][j + 1], a[i][j]}) - 1; } } int ans = -1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ ans = max(ans, max({dp1[i][j], dp2[i][j], dp3[i][j], dp4[i][j]}) - a[i][j]); } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...