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>
#include "railroad.h"
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;
ll plan_roller_coaster(std::vector<int> s, std::vector<int> t)
{
int N = s.size();
vector<vector<ll>> dp((1 << N), vector<ll>(N));
for (int mask = 1; mask < (1 << N); mask++)
{
if (__builtin_popcount(mask) == 1) continue;
for (int v = 0; v < N; v++)
{
if (!(mask & (1 << v))) continue;
dp[mask][v] = INF;
for (int v2 = 0; v2 < N; v2++)
{
if (v2 == v || !(mask & (1 << v2))) continue;
dp[mask][v] = min(dp[mask][v], dp[mask-(1 << v)][v2] + max(0LL, (ll)t[v2] - (ll)s[v]));
}
}
}
return *min_element(dp.back().begin(), dp.back().end());
}
# | 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... |