Submission #44697

#TimeUsernameProblemLanguageResultExecution timeMemory
44697adminMaxcomp (info1cup18_maxcomp)C++17
60 / 100
575 ms12636 KiB
#include <bits/stdc++.h> using namespace std; const int N_ = 1050, M_ = 1050; int N, M, A[N_][M_]; int ans = -int(1e9); void go() { vector< vector<int> > mn(N+1, vector<int>(M+1, int(1e9)+1)); vector< vector<int> > mx(N+1, vector<int>(M+1, -1)); for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) { int cur_min = min(mn[i][j-1], mn[i-1][j]); int cur_max = max(mx[i][j-1], mx[i-1][j]); ans = max(ans, max(A[i][j] - cur_min, -A[i][j] + cur_max) - (i + j) - 1); mn[i][j] = min(cur_min, A[i][j] - (i + j)); mx[i][j] = max(cur_max, A[i][j] + (i + j)); } } } int main() { cin >> N >> M; for(int i = 1; i <= N; i++) { for(int j = 1; j <= M; j++) { cin >> A[i][j]; } } // assert(1 <= N * M && N * M <= 20); go(); for(int i = 1; i <= N; i++) { reverse(A[i]+1, A[i]+M+1); } go(); cout << ans << endl; 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...