This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18 + 123;
ll find_shortcut(int n, vector<int> l, vector<int> d, int c) {
ll pref[n] = {};
for (int i = 0; i < n - 1; i ++) pref[i + 1] = pref[i] + l[i];
ll res = INF;
for (int l = 0; l < n; l ++) {
for (int r = l + 1; r < n; r ++) {
ll ans = 0;
for (int i = 0; i < n; i ++) {
ans = max(ans, 1ll * d[i]);
for (int j = i + 1; j < n; j ++) {
ll dist = min(pref[j] - pref[i], abs(pref[i] - pref[l]) + abs(pref[j] - pref[r]) + c) + d[i] + d[j];
ans = max(ans, dist);
}
}
res = min(res, ans);
}
}
return res;
}
# | 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... |
# | 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... |