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 int N = (1 << 17);
long long dp[17][N];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for(int i = 1; i < N; i ++)
for(int j = 0; j < n; j ++)
dp[j][i] = 1e18;
for(int i = 0; i < n; i ++){
dp[i][1 << i] = 0;
}
for(int mask = 1; mask < (1 << n); mask ++){
for(int i = 0; i < n; i ++){
if(mask & (1 << i)) continue;
int to = mask + (1 << i);
for(int j = 0; j < n; j ++){
if(!(mask & (1 << j))) continue;
dp[i][to] = min(dp[i][to], dp[j][mask] + max(t[j] - s[i], 0));
}
}
}
long long ans = 1e18;
for(int i = 0; i < n; i ++)
ans = min(ans, dp[i][(1 << n) - 1]);
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... |