Submission #197468

# Submission time Handle Problem Language Result Execution time Memory
197468 2020-01-21T12:09:52 Z Vladikus004 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
3 ms 424 KB
#include <bits/stdc++.h>
#define int long long
#define inf 2e9
#define ff first
#define ss second
#define all(v) v.begin() , v.end()
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 1000 + 3;
int a[N][N], dp1[N][N], dp2[N][N], dp3[N][N], dp4[N][N];
int n, m;

int32_t main()
{
    #ifdef VBH
        freopen("input.txt" , "r" , stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    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++)
        for (int j = 1; j <= m; j++)
            dp1[i][j] = max(a[i][j], max(dp1[i - 1][j], dp1[i][j - 1]) - 1);
    for (int i = n; i > 0; i--)
        for (int j = m; j > 0; j--)
            dp2[i][j] = max(a[i][j], max(dp2[i + 1][j], dp2[i][j + 1]) - 1);
    for (int i = n; i > 0; i--)
        for (int j = 1; j <= m; j++)
            dp3[i][j] = max(a[i][j], max(dp3[i - 1][j], dp3[i][j + 1]) - 1);
    for (int i = 1; i <= n; i++)
        for (int j = 0; j > 0; j--)
            dp4[i][j] = max(a[i][j], max(dp4[i + 1][j], dp4[i][j - 1]) - 1);
    int mx = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            mx = max(mx, max(max(dp1[i][j], dp2[i][j]), max(dp3[i][j], dp4[i][j])) - a[i][j]);
    cout << mx - 1;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 0 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 0 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 0 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -