#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define pb push_back
#define fst first
#define snd second
#define all(c) (c).begin(), (c).end()
typedef long long ll;
typedef long double ld;
const ll INF64 = 1e18 + 228;
const int INF32 = 1e9 + 1337;
const int MOD = 1e9 + 7;
const ld eps = 1e-7;
const int N = 1e3 + 3;
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef __WIN32
// ifstream cin("input.txt");
// ofstream cout("output.txt");
//#endif
int n, m;
cin >> n >> m;
vector<pair<ll, ll> > a(n * m);
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
{
ll x;
cin >> x;
a[i * m + j] = {x + i + j + 1, i + j + 1};
}
sort(all(a));
// for(auto& it : a)
// cout << it.fst << " " << it.snd << "\n";
// cout << "\n";
cout << a.back().fst - a[0].fst - 2 * abs(a.back().snd - a[0].snd) - 1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |