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;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<vector<long long>> dp((1<<n), vector<long long>(n,1e16));
long long kk=1;
int kkpos=0;
while(kkpos<n)
{
dp[kk][kkpos]=0;
kk=kk*2;
kkpos++;
}
for(int i=0;i<(1<<n);i++)
{
for(int j=0;j<n;j++)
{
if(((1<<j) & i)==0)
{
for(int k=0;k<n;k++)
{
if(((1<<k) & i)!=0)
{
long long distance=max((t[k]-s[j]),0);
dp[i | (1<<j)][j]=min(dp[i | (1<<j)][j],(dp[i][k] + distance));
}
}
}
}
}
long long minnimum=1e16;
for(int j=0;j<n;j++)
{
minnimum=min(minnimum,dp[1<<n][j]);
}
return minnimum;
}
# | 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... |