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 <algorithm>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn=17;
const ll inf=1e18;
int n;
ll dp[(1<<maxn)][maxn];
ll plan_roller_coaster(vector < int > s, vector < int > t){
n=s.size();
int x;
for(int i=1; i<(1<<n); i++){
for(int j=0; j<n; j++){
if(i&(1<<j)){
dp[i][j]=inf;
x=i^(1<<j);
if(!x){
dp[i][j]=0;
}
for(int k=0; k<n; k++){
if(x&(1<<k)){
dp[i][j]=min(dp[i][j], dp[x][k]+max(0, t[k]-s[j]));
}
}
}
}
}
ll mini=inf;
for(int i=0; i<n; i++){
mini=min(mini, dp[(1<<n)-1][i]);
}
return mini;
}
# | 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... |