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>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll dp[1<<16][16];
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
assert(n<=16);
memset(dp,0x3f,sizeof(dp));
rep(i,n){
dp[1<<i][i]=0;
}
rep(i,1<<n)rep(j,n){
if(dp[i][j]==INF)continue;
rep(k,n){
if(i>>k&1)continue;
ll cost=dp[i][j]+max(0,t[j]-s[k]);
dp[i|1<<k][k]=min(dp[i|1<<k][k],cost);
}
}
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... |