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>
using namespace std;
typedef long long ll;
ll dp[1<<17][17];
vector<int> s , t;
long long plan_roller_coaster(std::vector<int> sx, std::vector<int> tx){
int n = (int) sx.size();
s = sx , t = tx;
for(int i = 0 ; i < (1<<n) ; i ++){
for(int j = 0 ; j < n; j ++){
dp[i][j] = (ll) 1e18;
}
}
for(int i = 0 ; i < n;i ++){
dp[1<<i][i] = 0;
}
for(int i = 0 ; i < (1<<n) ; i ++){
for(int j = 0 ; j < n ; j ++){
if((1<<j) & i){
for(int k = 0 ; k < n ; k++){
if((1<<k) & (i^(1<<j))){
if(dp[i][j] > (dp[i^(1<<j)][k] + (ll)max(t[k] - s[j] , 0))){
dp[i][j] = min(dp[i][j] , dp[i^(1<<j)][k] + (ll)max(t[k] - s[j] , 0));
}
}
}
}
}
}
int L = (1<<n);
L--;
ll p = (ll) 1e18;
for(int j = 0 ; j < n ; j ++){
p = min(p , dp[L][j]);
}
return p;
}
# | 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... |