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 <bits/stdc++.h>
#include "railroad.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long
const int inf = 1e9;
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
ll dp[1 << n][n];
memset(dp, '?', sizeof dp);
memset(dp[(1 << n) - 1], 0, sizeof dp[(1 << n) - 1]);
for (int msk = (1 << n) - 2; msk >= 0; msk--) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if ((msk >> j) & 1) continue;
dp[msk][i] = min(dp[msk][i], dp[msk | (1 << j)][j] + max(0, (msk? t[i] - s[j] : 0)));
}
}
}
return dp[0][0];
}
# | 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... |