Submission #870934

#TimeUsernameProblemLanguageResultExecution timeMemory
870934borisAngelovMaxcomp (info1cup18_maxcomp)C++17
60 / 100
1014 ms8772 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...