# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1020722 | mansur | Roller Coaster Railroad (IOI16_railroad) | C++17 | 359 ms | 524288 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;
#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll inf = 1e18;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = sz(s);
if (n <= 16) {
ll dp[1 << n][n];
for (int msk = 0; msk < (1 << n); msk++) {
for (int i = 0; i < n; i++) {
dp[msk][i] = inf;
}
}
for (int i = 0; i < n; i++) dp[1 << i][i] = 0;
for (int msk = 1; msk < (1 << n); msk++) {
for (int i = 0; i < n; i++) {
if (msk >> i & 1) {
for (int j = 0; j < n; j++) {
if (msk >> j & 1) continue;
int msk1 = msk + (1 << j);
dp[msk1][j] = min(dp[msk1][j], dp[msk][i] + max(0, t[i] - s[j]));
}
}
}
}
ll ans = inf;
for (int i = 0; i < n; i++) ans = min(ans, dp[(1 << n) - 1][i]);
return ans;
}
}
Compilation message (stderr)
# | 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... |