Submission #464846

#TimeUsernameProblemLanguageResultExecution timeMemory
464846MKutayBozkurtMaxcomp (info1cup18_maxcomp)C++14
100 / 100
137 ms24648 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define int long long int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> a(n + 2, vector<int>(m + 2)), dp(n + 2, vector<int>(m + 2)); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = a[i][j]; dp[i][j] = max(dp[i][j], dp[i - 1][j] - 1); dp[i][j] = max(dp[i][j], dp[i][j - 1] - 1); } } for (int i = n; i >= 1; i--) { for (int j = m; j >= 1; j--) { dp[i][j] = max(dp[i][j], dp[i + 1][j] - 1); dp[i][j] = max(dp[i][j], dp[i][j + 1] - 1); } } int ans = -1e9; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { ans = max(ans, dp[i][j] - a[i][j] - 1); } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...