Submission #870934

# Submission time Handle Problem Language Result Execution time Memory
870934 2023-11-09T13:41:30 Z borisAngelov Maxcomp (info1cup18_maxcomp) C++17
60 / 100
500 ms 8772 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")

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 1 ms 448 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 476 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 1 ms 448 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 10 ms 2648 KB Output is correct
10 Correct 9 ms 2652 KB Output is correct
11 Correct 13 ms 2652 KB Output is correct
12 Correct 9 ms 2648 KB Output is correct
13 Correct 11 ms 2676 KB Output is correct
14 Correct 12 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 2 ms 476 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 10 ms 2648 KB Output is correct
13 Correct 9 ms 2652 KB Output is correct
14 Correct 13 ms 2652 KB Output is correct
15 Correct 9 ms 2648 KB Output is correct
16 Correct 11 ms 2676 KB Output is correct
17 Correct 12 ms 2652 KB Output is correct
18 Execution timed out 1014 ms 8772 KB Time limit exceeded
19 Halted 0 ms 0 KB -