제출 #1143139

#제출 시각아이디문제언어결과실행 시간메모리
1143139AgageldiMaxcomp (info1cup18_maxcomp)C++17
60 / 100
1093 ms12356 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 600005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sz(s) (int)s.size()
#define pii pair<int,int>

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll T, n, a[2000][2000], t, m, answer = -1, vis[2000][2000], dp[2000][2000];
vector <pair<int,int>> path, ans;

int main () {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m;
	bool tr = 0;
	for(int i = 1;i <= n;i++) {
		for(int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j= 1;j<=m;j++) {
			for(int k = 1; k <= n; k++) {
				for(int l= 1;l<=m;l++) {
					if(i == k && j == l) continue;
					answer = max(answer, abs(a[i][j] - a[k][l]) - abs(i - k) - abs(j - l) - 1);
				}
			}
		}
	}
	cout << answer << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...