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>
const int N = 16;
long long INF = 1e16;
long long dp[1 << N][N];
using namespace std;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for (int mask = 1; mask < (1 << n); mask++) {
for (int i = 0; i < n; i++) {
dp[mask][i] = INF;
if ((mask & (1 << i)) == 0) continue;
int p_mask = (mask ^ (1 << i));
if (p_mask == 0) dp[mask][i] = 0;
for (int j = 0; j < n; j++) {
if (p_mask & (1 << j)) {
dp[mask][i] = min(dp[mask][i], dp[p_mask][j] + max(0, t[j] - s[i]));
}
}
}
}
return *min_element(dp[(1 << n) - 1], dp[(1 << n) - 1] + n);
}
# | 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... |