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>
#ifndef _DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include "railroad.h"
#endif
using namespace std;
long long plan_roller_coaster(vector<int> s, vector<int> t)
{
int n = s.size();
vector<vector<int64_t>> dp((1 << n) + 1, vector<int64_t>(n, 1e16));
dp[0][0] = 0;
for (int i = 0; i < n; i++)
{
dp[1 << i][i] = 0;
}
for (int bits = 1; bits < (1 << n) + 1; bits++)
for (int i = 0; i < n; i++)
{
if (!(bits & (1 << i)))
continue;
for (int j = 0; j < n; j++)
{
if (i == j || !(bits & (1 << j)))
continue;
dp[bits][i] = min(dp[bits][i], dp[bits ^ (1 << i)][j] + max(t[j] - s[i], 0));
}
}
return *min_element(dp[(1 << n) - 1].begin(), dp[(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... |