#include <iostream>
#include <map>
using namespace std;
int main()
{
long long int n, m;
cin >> n >> m;
multimap<long long int, pair<long long int, long long int>> matrix;
long long int x;
for(long long int i = 0; i < n; i++) for(long long int j = 0; j < m; j++)
{
cin >> x;
matrix.emplace(x, pair<long long int, long long int>(i, j));
}
long long int w = -1;
for(auto it = matrix.begin(); it != matrix.end(); it++) for(auto itt = matrix.begin(); itt != matrix.end(); itt++)
{
w = max(w, abs(it->first - itt->first) - abs(it->second.first - itt->second.first) - abs(it->second.second - itt->second.second) - 1);
}
cout << w << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
252 KB |
Output is correct |
7 |
Correct |
2 ms |
352 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
376 KB |
Output is correct |
2 |
Correct |
12 ms |
376 KB |
Output is correct |
3 |
Correct |
9 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
252 KB |
Output is correct |
7 |
Correct |
2 ms |
352 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
64 ms |
508 KB |
Output is correct |
10 |
Correct |
62 ms |
504 KB |
Output is correct |
11 |
Correct |
57 ms |
632 KB |
Output is correct |
12 |
Correct |
58 ms |
504 KB |
Output is correct |
13 |
Correct |
62 ms |
504 KB |
Output is correct |
14 |
Correct |
61 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
252 KB |
Output is correct |
7 |
Correct |
2 ms |
352 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
10 ms |
376 KB |
Output is correct |
10 |
Correct |
12 ms |
376 KB |
Output is correct |
11 |
Correct |
9 ms |
376 KB |
Output is correct |
12 |
Correct |
64 ms |
508 KB |
Output is correct |
13 |
Correct |
62 ms |
504 KB |
Output is correct |
14 |
Correct |
57 ms |
632 KB |
Output is correct |
15 |
Correct |
58 ms |
504 KB |
Output is correct |
16 |
Correct |
62 ms |
504 KB |
Output is correct |
17 |
Correct |
61 ms |
632 KB |
Output is correct |
18 |
Execution timed out |
1083 ms |
49848 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |