Submission #46791

#TimeUsernameProblemLanguageResultExecution timeMemory
46791jun6873Maxcomp (info1cup18_maxcomp)C++11
100 / 100
165 ms8456 KiB
#include <bits/stdc++.h> using namespace std; int h, w, a[1004][1004], mx[1004][1004]; int solve() { for (int i=0; i<=h; i++) for (int j=0; j<=w; j++) mx[i][j] = -2e9; int ret = -1; for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) { int k = i + j - a[i][j]; mx[i][j] = max({mx[i-1][j], mx[i][j-1], k}); ret = max(ret, mx[i][j] - k - 1); } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> h >> w; for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) cin >> a[i][j]; int ans = solve(); for (int i=1; i<=h; i++) for (int j=1; j<=w/2; j++) swap(a[i][j], a[i][w-j+1]); ans = max(ans, solve()); for (int i=1; i<=h/2; i++) for (int j=1; j<=w; j++) swap(a[i][j], a[h-i+1][j]); ans = max(ans, solve()); for (int i=1; i<=h; i++) for (int j=1; j<=w/2; j++) swap(a[i][j], a[i][w-j+1]); ans = max(ans, solve()); 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...