답안 #197465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197465 2020-01-21T12:08:48 Z Vladikus004 Maxcomp (info1cup18_maxcomp) C++14
15 / 100
2 ms 476 KB
#include <bits/stdc++.h>
#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;

int 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 476 KB Output is correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -