Submission #1174454

#TimeUsernameProblemLanguageResultExecution timeMemory
1174454browntoadMaxcomp (info1cup18_maxcomp)C++20
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long // #define int ll #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 1, n+1) #define RREP(i, n) for (int i = (n)-1; i >= 0; i--) #define pii pair<int, int> #define pip pair<int, pii> #define f first #define s second #define pb push_back #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #ifdef TOAD #define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #else #define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #endif // TOAD const ll maxn = 1e3+5; const int iinf = 1e9+5; int n, m; int arr[maxn][maxn]; vector<int> dx = {1, 1, -1, -1}; vector<int> dy = {-1, 1, -1, 1}; signed main(){ IOS(); cin>>n>>m; int ans = -1; vector<pip> pus; REP(i, n){ REP(j, m){ cin>>arr[i][j]; pus.pb({arr[i][j], {i, j}}); } } sort(ALL(pus)); vector<int> mn(4); REP(i, 4) mn[i] = iinf; for (auto pp:pus){ REP(i, 4){ mn[i] = min(mn[i], pp.f + dx[i] * pp.s.f + dy[i] * pp.s.s); } int mox = -iinf; REP(i, 4){ mox = max(mox, -mn[i] + pp.f + dx[i] * pp.s.f + dy[i] * pp.s.s - 1); } ans = max(ans, mox); } cout<<ans<<endl; } /* 2 3 2 4 3 5 7 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...