# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
492616 | dxz05 | Roller Coaster Railroad (IOI16_railroad) | C++14 | 52 ms | 13876 KiB |
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;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = (int) s.size();
vector<vector<ll>> dp(1 << n, vector<ll>(n, 1e18));
for (int i = 0; i < n; i++) dp[1 << i][i] = 0;
for (int mask = 0; mask < (1 << n); mask++){
for (int i = 0; i < n; i++){
if (!(mask & (1 << i))) continue;
for (int j = 0; j < n; j++){
if (!(mask & (1 << j))) continue;
dp[mask][i] = min(dp[mask][i], dp[mask ^ (1 << i)][j] + max(0, t[j] - s[i]));
}
}
}
ll res = 1e18;
for (int i = 0; i < n; i++) res = min(res, dp[(1 << n) - 1][i]);
return res;
}
# | 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... |