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;
using ll = long long;
const ll LINF = (ll)2e18;
ll dp[1<<16][16];
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = (int)s.size();
for(int i = 0; i < (1<<n); i++)
for(int j = 0; j < n; j++) dp[i][j]=LINF;
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((mask>>i)&1)
for(int j = 0; j < n; j++)
if((mask>>j)&1 and j!=i)
dp[mask][i] = min(dp[mask][i],
dp[mask^(1<<i)][j]+(ll)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... |