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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
//#define int ll
#include "railroad.h"
ll dp[70005][25];
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
for(int i=0;i<(1<<n);i++){
for(int j=0;j<n;j++){
dp[i][j] = 2e18;
}
}
for(int i=1;i<(1<<n);i++){
int cnt=0;
for(int j=0;j<n;j++){
if(i&(1<<j)){
cnt++;
}
}
if(cnt==1){
for(int j=0;j<n;j++){
if(i&(1<<j)){
dp[i][j] = 0;
}
}
continue;
}
for(int j=0;j<n;j++){
if(i&(1<<j)){
int p = i-(1<<j);
for(int k=0;k<n;k++){
if(p&(1<<k)){
dp[i][j] = min(dp[i][j],dp[p][k]+max(0,t[k]-s[j]));
}
}
}
}
}
ll ans=2e18;
for(int 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... |