This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#define int long long
using namespace std;
int a[1005][1005];
int dist(int x1, int y1, int x2, int y2)
{
return abs(x1 - x2) + abs(y1 - y2);
}
signed main()
{
int n, m;
cin>>n>>m;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin>>a[i][j];
int maxx = -1;
for(int i1 = 1; i1 <= n; i1++)
{
for(int j1 = 1; j1 <= m; j1++)
{
for(int i2 = 1; i2 <= n; i2++)
{
for(int j2 = 1; j2 <= m; j2++)
{
if(i1 != j1 || i2 != j2)
maxx = max(maxx, a[i2][j2] - a[i1][j1] - dist(i1, j1, i2, j2));
}
}
}
}
cout<<maxx<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |