Submission #84090

#TimeUsernameProblemLanguageResultExecution timeMemory
84090alextodoranMaxcomp (info1cup18_maxcomp)C++14
60 / 100
509 ms20308 KiB
#include <bits/stdc++.h> #define NM 1002 using namespace std; int n, m; int ma[NM][NM]; int mx1[NM][NM], mx2[NM][NM], mx3[NM][NM], mx4[NM][NM], mx = -1; int main() { cin >> n >> m; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> ma[i][j]; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) mx1[i][j] = max(max(mx1[i - 1][j], mx1[i][j - 1]) - 1, ma[i][j] - 1); for(int i = 1; i <= n; i++) for(int j = m; j >= 1; j--) mx2[i][j] = max(max(mx2[i - 1][j], mx2[i][j + 1]) - 1, ma[i][j] - 1); for(int i = n; i >= 1; i--) for(int j = 1; j <= m; j++) mx3[i][j] = max(max(mx3[i + 1][j], mx3[i][j - 1]) - 1, ma[i][j] - 1); for(int i = n; i >= 1; i--) for(int j = m; j >= 1; j--) mx4[i][j] = max(max(mx4[i + 1][j], mx4[i][j + 1]) - 1, ma[i][j] - 1); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) mx = max(mx, max(max(mx1[i][j], mx2[i][j]), max(mx3[i][j], mx4[i][j])) - ma[i][j]); cout << mx << "\n"; 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...