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 "shortcut.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
long long find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
ll ans = 1e18;
vector<ll> p(n);
for (int i = 1; i < n; i++) p[i] = p[i-1] + l[i-1];
for (int i = 0; i < n; i++) {
for (int j = i+1; j < n; j++) {
ll cur = 0;
for (int k = 0; k <= i; k++) {
for (int l = k+1; l <= j; l++) {
ckmax(cur, d[k] + d[l] + min(p[l], p[i] + p[j] - p[l] + c) - p[k]);
}
for (int l = max(k+1, j+1); l < n; l++) {
ckmax(cur, d[k] + d[l] + p[l] - p[k]);
}
}
for (int k = i+1; k < n; k++) {
for (int l = k+1; l <= j; l++) {
ckmax(cur, d[k] + d[l] + min(p[l] - p[k], p[k] - p[i] + p[j] - p[l] + c));
}
for (int l = max(j+1, k+1); l < n; l++) {
ckmax(cur, d[k] + d[l] + p[l] - p[k]);
}
}
ckmin(ans, cur);
}
}
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... |