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 ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
#define ld long double
using namespace :: std;
const ll maxn=17;
const ll inf=1e17+900;
ll ger[maxn][maxn];
ll dp[1<<maxn][maxn];
long long plan_roller_coaster(vector<int> s,vector<int> t) {
int n = (int) s.size();
for(ll i=0;i<n;i++){
for(ll j=0;j<n;j++){
ger[i][j]=max(0,t[i]-s[j]);
}
}
for(ll i=1;i<(1<<n);i++){
for(ll j=0;j<n;j++){
if(i!=(1<<j)){
if((i>>j)&1){
dp[i][j]=inf;
for(ll k=0;k<n;k++){
if(((i>>k)&1) && k!=j){
dp[i][j]=min(dp[i][j],dp[i^(1<<j)][k]+ger[j][k]);
}
}
}
}
}
}
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... |