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;
typedef long long LL;
const LL INF=1e18;
LL dp[(1<<16)][16];
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = (int) s.size();
for(LL i=0;i<(1<<n);i++){
for(LL j=0;j<n;j++){
dp[i][j]=INF;
}
}
for(LL i=0;i<n;i++)dp[(1<<i)][i]=0;
for(LL i=0;i<(1<<n);i++){
for(LL j=0;j<n;j++){
if(i & (1<<j)){
for(LL k=0;k<n;k++){
if(!(i & (1<<k))){
dp[i+(1<<k)][k]=min(dp[i+(1<<k)][k],dp[i][j]+max(t[k]-s[j],0));
}
}
}
}
}
LL ans=INF;
for(LL 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... |