# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497087 | kingline | Maxcomp (info1cup18_maxcomp) | C++17 | 1093 ms | 15880 KiB |
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 <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define pii pair < int, int >
using namespace std;
int n, m, c[1005][1005];
pair < int, pii > v[1000005];
main() {
//file("pieaters");
/*ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
//cin >> n >> m;
scanf("%d%d", &n, &m);
int num = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
//cin >> c[i][j];
scanf("%d", &c[i][j]);
v[num] = {c[i][j], {i, j}};
num++;
}
}
sort(v + 1, v + n * m + 1);
int ans = -1;
for(int i = n * m; i > 0; i--) {
for(int j = i - 1; j > 0; j--) {
ans = max(ans, v[i].first - v[j].first - abs(v[i].second.first - v[j].second.first) - abs(v[i].second.second - v[j].second.second) - 1);
}
}
printf("%d", ans);
}
Compilation message (stderr)
# | 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... |