Submission #870930

#TimeUsernameProblemLanguageResultExecution timeMemory
870930borisAngelovMaxcomp (info1cup18_maxcomp)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; const int inf = 2e9; int n, m; int a[maxn][maxn]; void fastIO() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); cin >> n >> m; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> a[i][j]; } } 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 = min(ans, abs(a[x1][y1] - a[x2][y2]) + abs(x1 - x2) + abs(y1 - y2)); } } } } } cout << ans << 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...