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 "railroad.h"
#include "bits/stdc++.h"
using namespace std;
const long long INF = 1e18;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<vector<long long>> dp(1 << n, vector<long long> (n, INF));
for (int i = 0; i < n; ++i) {
dp[1 << i][i] = 0;
}
for (int msk = 1; msk < (1 << n); ++msk) {
for (int i = 0; i < n; ++i) {
if (!(msk >> i & 1)) continue;
for (int j = 0; j < n; ++j) {
if (msk >> j & 1) continue;
dp[msk | (1 << j)][j] = min(dp[msk | (1 << j)][j], dp[msk][i] + max(0, t[i] - s[j]));
}
}
}
long long ans = INF;
for (int i = 0; i < n; ++i) {
ans = min(ans, dp[(1 << n) - 1][i]);
}
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... |