# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44907 | ulna | Maxcomp (info1cup18_maxcomp) | C++11 | 200 ms | 4732 KiB |
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;
// why am I so weak
int n, m;
int a[1055][1055];
int dp[1055];
int solve() {
int res = -INT_MAX;
for (int j = 0; j < m; j++) {
dp[j] = -(int)1e9;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
dp[j]--;
}
{
int roll = -(int)1e9;
for (int j = 0; j < m; j++) {
roll--;
roll = max(roll, -a[i][j] - 1);
roll = max(roll, dp[j]);
dp[j] = roll;
}
}
{
int roll = -(int)1e9;
for (int j = m - 1; j >= 0; j--) {
roll--;
roll = max(roll, -a[i][j] - 1);
roll = max(roll, dp[j]);
dp[j] = roll;
}
}
for (int j = 0; j < m; j++) {
res = max(res, a[i][j] + dp[j]);
}
}
return res;
}
int main() {
scanf("%d %d", &n, &m);
for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
scanf("%d", &a[i][j]);
}
int res = -1;
res = max(res, solve());
for (int i = 0; i < n / 2; i++) {
swap(a[i], a[n - i - 1]);
}
res = max(res, solve());
cout << res << endl;
return 0;
}
Compilation message (stderr)
# | 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... |