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;
using ll = long long;
ll dp[17][1 << 16];
int n;
vector<int> s, t;
ll f(int u, int mask) {
if(mask == (1 << n) - 1) return 0;
ll &ret = dp[u][mask];
if(ret != -1) return ret;
ret = INT_MAX;
for(int i = 0; i < n; i++) if(mask & (1 << i)) {} else {
ret = min(ret, max(0, t[u] - s[i]) + f(i, mask | (1 << i)));
}
return ret;
}
ll plan_roller_coaster(vector<int> _s, vector<int> _t) {
s = _s, t = _t;
n = (int) s.size();
memset(dp, -1, sizeof dp);
ll ret = INT_MAX;
for(int i = 0; i < n; i++) {
ret = min(ret, f(i, 1 << i));
}
return ret;
}
# | 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... |