# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780793 | 2023-07-12T13:14:03 Z | Andrey | Maxcomp (info1cup18_maxcomp) | C++14 | 1 ms | 324 KB |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m,a,b,ans = 0; cin >> n >> m; int haha[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> haha[i][j]; } } pair<int,int> dp[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { dp[i][j] = {haha[i][j]+i+j,-haha[i][j]+i+j}; if(i > 0) { dp[i][j] = {max(dp[i][j].first,dp[i-1][j].first),max(dp[i][j].second,dp[i-1][j].second)}; } if(j > 0) { dp[i][j] = {max(dp[i][j].first,dp[i][j-1].first),max(dp[i][j].second,dp[i][j-1].second)}; } ans = max(ans,dp[i][j].first-haha[i][j]-i-j); ans = max(ans,dp[i][j].second+haha[i][j]-i-j); } } for(int i = 0; i < n; i++) { for(int j = 0; j < n/2; j++) { swap(haha[i][j],haha[i][m-j-1]); } } for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { dp[i][j] = {haha[i][j]+i+j,-haha[i][j]+i+j}; if(i > 0) { dp[i][j] = {max(dp[i][j].first,dp[i-1][j].first),max(dp[i][j].second,dp[i-1][j].second)}; } if(j > 0) { dp[i][j] = {max(dp[i][j].first,dp[i][j-1].first),max(dp[i][j].second,dp[i][j-1].second)}; } ans = max(ans,dp[i][j].first-haha[i][j]-i-j); ans = max(ans,dp[i][j].second+haha[i][j]-i-j); } } cout << ans-1; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 324 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |