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;
#define int long long
long long plan_roller_coaster(vector<int32_t> s, vector<int32_t> t) {
int n=(int)s.size();
vector<vector<int>> f(1<<n, vector<int>(n, 1e18));
for (int i=0; i<n; ++i) f[1<<i][i]=0;
for (int i=0; i<(1<<n); ++i) for (int j=0; j<n; ++j) if (i>>j&1 && f[i][j]<1e18){
for (int k=0; k<n; ++k) if (!(i>>k&1)){
f[i|1<<k][k]=min(f[i|1<<k][k], f[i][j]+max(0, t[j]-s[k]));
}
}
return *min_element(f[(1<<n)-1].begin(), f[(1<<n)-1].end());
}
# | 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... |