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>
using i64 = long long;
template <typename T> using Vec = std::vector<T>;
constexpr int inf = 1100000000;
constexpr i64 inf64 = 2000000000000000000;
template <typename T> bool setmin(T &a, const T v) {
if (a > v) {
a = v;
return true;
}
return false;
}
template <typename T> bool setmax(T &a, const T v) {
if (a < v) {
a = v;
return true;
}
return false;
}
long long find_shortcut(int N, std::vector<int> L, std::vector<int> D, int C) {
std::vector<i64> S(N);
for (int i = 0; i < N - 1; ++i) S[i + 1] = S[i] + L[i];
i64 ans = inf64;
for (int a = 0; a < N; ++a) {
for (int b = a + 1; b < N; ++b) {
i64 res = 0;
for (int x = 0; x < N; ++x) {
for (int y = x + 1; y < N; ++y) {
i64 c1 = D[x] + D[y];
i64 c2 = S[y] - S[x];
i64 c3 = (y > b) ? (S[y] - S[b]) : (S[b] - S[y]);
i64 c4 = (x > a) ? (S[x] - S[a]) : (S[a] - S[x]);
setmax(res, c1 + std::min(c2, c3 + c4 + C));
}
}
setmin(ans, res);
}
}
return ans;
}
# | 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... |