Submission #497092

#TimeUsernameProblemLanguageResultExecution timeMemory
497092kinglineMaxcomp (info1cup18_maxcomp)C++17
60 / 100
1080 ms15924 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("unroll-loops,Ofast,O3") #pragma GCC target("avx,avx2,fma") using namespace std; int n, m, c[1005][1005]; pair < int, pair < int, int > > v[1000005]; main() { //file("pieaters"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; int num = 1; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> c[i][j]; v[num] = {c[i][j], {i, j}}; num++; } } n *= m; int ans = -1; for(int i = n; i > 1; i--) { for(int j = i - 1; j > 0; j--) { ans = max(ans, abs(v[i].first - v[j].first) - abs(v[i].second.first - v[j].second.first) - abs(v[i].second.second - v[j].second.second) - 1); } } cout << ans; }

Compilation message (stderr)

maxcomp.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...