답안 #639305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639305 2022-09-09T11:54:37 Z LucaLucaM Maxcomp (info1cup18_maxcomp) C++17
15 / 100
2 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

struct cell
{
    long long x;
    int i, j;
};

bool comp (cell a, cell b)
{
    return !(a.x > b.x);
}

cell a[1000001];

int main()
{
    int n, m;
    cin >> n >> m;

    int N = 0;

    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=m; j++)
        {
            int x;
            cin >> x;

            N++;
            a[N].x = x;
            a[N].i = i, a[N].j = j;
        }
    }

    sort (a+1, a+N+1, comp);

    long long ans = 0;

    for (int i=1; i<N; i++)
    {
        for (int j=N; j>i; j--)
        {
            long long d = abs(a[i].i - a[j].i) + abs(a[i].j - a[j].j) + 1;
            long long s = a[j].x - a[i].x - d;

            ans = max(ans, s);
        }
    }

    cout << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -