Submission #639301

# Submission time Handle Problem Language Result Execution time Memory
639301 2022-09-09T11:43:55 Z LucaLucaM Maxcomp (info1cup18_maxcomp) C++17
15 / 100
1 ms 312 KB
#include <bits/stdc++.h>

using namespace std;

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

bool operator < (const cell a, const cell b)
{
    return a.x <= b.x;
}

cell a[1000001];

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

    int N = 0;

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

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

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

    int M = N/2 + 1;
    int ans = 0;

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

            ans = max(ans, s);
        }
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -