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;
#define ll long long
ll lowbit(int x){return x&-x;}
ll dp[(1<<17)][20];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
for(int i=1;i<(1<<n);i++){
for(int j=0;j<n;j++){
dp[i][j]=1e16;
if( ((i&(1<<j))==0)){continue;}
if(__builtin_popcount(i)==1){
dp[i][j]=0;
continue;
}
for(int k=0;k<n;k++){
if( !(i&(1<<k)) ){continue;}
if(k==j){continue;}
ll cst=dp[i^(1<<j)][k]+max(0,t[k]-s[j]);
dp[i][j]=min(dp[i][j],cst);
}
}
}
long long ret=dp[(1<<n)-1][0];
for(int j=0;j<n;j++){
ret=min(ret,dp[(1<<n)-1][j]);
}
return ret;
}
# | 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... |