This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define inf -1e9
int main(void) {
int n, m;
cin >> n >> m;
vector <vector <int> > g(n, vector <int> (m));
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) cin >> g[i][j];
}
vector <vector <int> > lu, ru, ld, rd;
rd.resize(n, vector <int> (m, inf));
lu.resize(n, vector <int> (m, inf));
ru.resize(n, vector <int> (m, inf));
ld.resize(n, vector <int> (m, inf));
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) {
rd[i][j] = g[i][j] + i + j;
if(i) rd[i][j] = min(rd[i][j], rd[i-1][j]);
if(j) rd[i][j] = min(rd[i][j], rd[i][j-1]);
}
}
int ans = -1e9;
for(int i = 0; i < n; i ++) {
for(int j = 0; j < m; j ++) {
ans = max(ans, g[i][j] - rd[i][j] - (i+j));
}
}
cout << ans-1;
return false;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |