제출 #1315859

#제출 시각아이디문제언어결과실행 시간메모리
1315859penguin133Maxcomp (info1cup18_maxcomp)C++20
15 / 100
1 ms332 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; int n, m, a[1005][1005], b[1005][1005], c[1005][1005]; int main() { cin >> n >> m; 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++) { b[i][0] = 2e9; c[i][m + 1] = 2e9; } for (int i = 1; i <= m; i++) b[0][i] = c[0][i] = 2e9; int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { ans = max(ans, a[i][j] - i - j - min(b[i][j - 1], b[i - 1][j])); b[i][j] = min({b[i - 1][j], b[i][j - 1], a[i][j] - i - j}); } } for (int i = 1; i <= n; i++) { for (int j = m; j >= 1; j--) { ans = max(ans, a[i][j] - i + j - min(c[i][j + 1], c[i - 1][j])); c[i][j] = min({c[i - 1][j], c[i][j + 1], a[i][j] - i + j}); } } cout << ans - 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...