Submission #870933

# Submission time Handle Problem Language Result Execution time Memory
870933 2023-11-09T13:41:00 Z borisAngelov Maxcomp (info1cup18_maxcomp) C++17
60 / 100
500 ms 4228 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1005;
const int inf = 2e9;

int n, m;

int a[maxn][maxn];

char s;
int num;

int read()
{
    num = 0;
    s = getchar();

    while (s < '0' || s > '9')
    {
        s = getchar();
    }

    while ('0' <= s && s <= '9')
    {
        num = num * 10 + (s - '0');
        s = getchar();
    }

    return num;
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    n = read();
    m = read();

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            a[i][j] = read();
        }
    }

    int ans = -inf;

    for (int x1 = 1; x1 <= n; ++x1)
    {
        for (int y1 = 1; y1 <= m; ++y1)
        {
            for (int x2 = 1; x2 <= n; ++x2)
            {
                for (int y2 = 1; y2 <= m; ++y2)
                {
                    if (x1 != x2 || y1 != y2)
                    {
                        ans = max(ans, abs(a[x1][y1] - a[x2][y2]) - (abs(x1 - x2) + abs(y1 - y2)));
                    }
                }
            }
        }
    }

    cout << ans - 1 << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 12 ms 2652 KB Output is correct
10 Correct 14 ms 2652 KB Output is correct
11 Correct 15 ms 2700 KB Output is correct
12 Correct 12 ms 2904 KB Output is correct
13 Correct 12 ms 2652 KB Output is correct
14 Correct 17 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 12 ms 2652 KB Output is correct
13 Correct 14 ms 2652 KB Output is correct
14 Correct 15 ms 2700 KB Output is correct
15 Correct 12 ms 2904 KB Output is correct
16 Correct 12 ms 2652 KB Output is correct
17 Correct 17 ms 2652 KB Output is correct
18 Execution timed out 1086 ms 4228 KB Time limit exceeded
19 Halted 0 ms 0 KB -