Submission #95029

#TimeUsernameProblemLanguageResultExecution timeMemory
95029Osama_AlkhodairyMaxcomp (info1cup18_maxcomp)C++17
15 / 100
2 ms508 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long int n, m, grid[1001][1001], mn[1001][1001]; int solve(){ for(int i = 0 ; i <= n ; i++) for(int j = 0 ; j <= m ; j++) mn[i][j] = 1e9; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) grid[i][j] -= i + j; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) mn[i][j] = min(mn[i - 1][j], min(mn[i][j - 1], grid[i][j])); int ret = 0; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) ret = max(ret, grid[i][j] - mn[i][j]); for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) grid[i][j] += i + j; return ret; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) cin >> grid[i][j]; int ans = solve(); for(int i = 1 ; i <= n ; i++){ int l = 1, r = m; while(l <= r){ swap(grid[i][l], grid[i][r]); l++; r--; } } ans = max(ans, solve()); cout << ans - 1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...