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>
#define lli long long int
using namespace std;
const int N = 1e5 + 30;
int n;
lli dp[20][N], mn = 1e11;
long long plan_roller_coaster(vector<int> s, vector<int> t)
{
n = s.size();
for (int x = 0; x < (1 << n); x++)
{
for (int i = 0; i < n; i++)
{
if((1 << i) & x)
{
if(x - (1 << i) == 0) continue;
dp[i][x] = 1e11;
for (int j = 0; j < n; j++)
{
if(i == j) continue;
if((1 << j) & x) dp[i][x] = min(max(0, t[i] - s[j]) + dp[j][x - (1 << i)], dp[i][x]);
}
}
}
}
for (int i = 0; i < n; i++)
{
mn = min(dp[i][(1 << n) - 1], mn);
}
return mn;
}
# | 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... |