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 = 1e18L + 20;
long long dp[1 << 16][16];
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
for (int mask = 0; mask < (1 << n); mask++) {
for (int i = 0; i < n; i++) {
dp[mask][i] = inf;
}
}
for (int i = 0; i < n; i++) {
dp[1 << i][i] = 0;
}
for (int mask = 1; mask < (1 << n); mask++) {
for (int i = 0; i < n; i++) {
if (dp[mask][i] == inf) {
continue;
}
for (int j = 0; j < n; j++) {
if (((mask >> j) & 1) == 0) {
dp[mask | (1 << j)][j] = min(dp[mask | (1 << j)][j], dp[mask][i] + max(t[i] - s[j], 0));
}
}
}
}
long long res = inf;
for (int i = 0; i < n; i++) {
res = min(res, dp[(1 << n) - 1][i]);
}
return res;
}
# | 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... |