Submission #494703

#TimeUsernameProblemLanguageResultExecution timeMemory
494703syl123456Maxcomp (info1cup18_maxcomp)C++17
100 / 100
176 ms20688 KiB
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wparentheses" #include <bits/stdc++.h> #define all(i) (i).begin(), (i).end() #define random random_device rd; mt19937 rng(rd()) using namespace std; template<typename T1, typename T2> ostream& operator << (ostream &i, pair<T1, T2> j) { return i << j.first << ' ' << j.second; } template<typename T> ostream& operator << (ostream &i, vector<T> j) { i << '{' << j.size() << ':'; for (T ii : j) i << ' ' << ii; return i << '}'; } void Debug(bool _split) {} template<typename T1, typename ...T2> void Debug(bool _split, T1 x, T2 ...args) { if (_split) cerr << ", "; cerr << x, Debug(true, args...); } template<typename T> void Debuga(T *i, int n) { cerr << '['; for (int j = 0; j < n; ++j) cerr << i[j] << " ]"[j == n - 1]; cerr << endl; } #ifdef SYL #define debug(args...) cerr << "Line(" << __LINE__ << ") -> [" << #args << "] is [", Debug(false, args), cerr << ']' << endl #define debuga(i) cerr << "Line(" << __LINE__ << ") -> [" << #i << "] is ", Debuga(i, sizeof(i) / sizeof(typeid(*i).name())) #else #define debug(args...) void(0) #define debuga(i) void(0) #endif typedef long long ll; typedef pair<int, int> pi; const int inf = 0x3f3f3f3f, lg = 20; const ll mod = 1e9 + 7, INF = 0x3f3f3f3f3f3f3f3f; signed main() { ios::sync_with_stdio(0), cin.tie(0); int n, m; cin >> n >> m; int a[n][m]; ll dp[n][m], ans = -1; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cin >> a[i][j]; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) { dp[i][j] = a[i][j]; if (i) dp[i][j] = max(dp[i][j], dp[i - 1][j] - 1); if (j) dp[i][j] = max(dp[i][j], dp[i][j - 1] - 1); ans = max(ans, dp[i][j] - a[i][j] - 1); } for (int i = 0; i < n; ++i) for (int j = m - 1; ~j; --j) { dp[i][j] = a[i][j]; if (i) dp[i][j] = max(dp[i][j], dp[i - 1][j] - 1); if (j + 1 < m) dp[i][j] = max(dp[i][j], dp[i][j + 1] - 1); ans = max(ans, dp[i][j] - a[i][j] - 1); } for (int i = n - 1; ~i; --i) for (int j = 0; j < m; ++j) { dp[i][j] = a[i][j]; if (i + 1 < n) dp[i][j] = max(dp[i][j], dp[i + 1][j] - 1); if (j) dp[i][j] = max(dp[i][j], dp[i][j - 1] - 1); ans = max(ans, dp[i][j] - a[i][j] - 1); } for (int i = n - 1; ~i; --i) for (int j = m - 1; ~j; --j) { dp[i][j] = a[i][j]; if (i + 1 < n) dp[i][j] = max(dp[i][j], dp[i + 1][j] - 1); if (j + 1 < m) dp[i][j] = max(dp[i][j], dp[i][j + 1] - 1); ans = max(ans, dp[i][j] - a[i][j] - 1); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...