Submission #1171330

#TimeUsernameProblemLanguageResultExecution timeMemory
1171330lopkusMaxcomp (info1cup18_maxcomp)C++20
15 / 100
1 ms328 KiB
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  std::cin >> n >> m;
  std::vector<std::vector<int64_t>> a(n + 1, std::vector<int64_t>(m + 1));
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      std::cin >> a[i][j];
    }
  }
  int64_t ans = 0;
  for(int x = 1; x <= n; x++) {
    for(int y = 1; y <= m; y++) {
      for(int x1 = 1; x1 <= n; x1++) {
        for(int y1 = 1; y1 <= m; y1++) {
          int64_t cost = a[x][y] - a[x1][y1];
          int64_t path = abs(x - x1) + abs(y - y1) + 1;
          ans = std::max(ans, cost - path);
        }
      }
    }
  }
  std::cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...