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