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 <cstdio>
#include <cassert>
#include<bits/stdc++.h>
using namespace std;
long long n,ans=1e18,sum;
vector<int>en,ex;
void f(int mask,long long sp)
{
if(mask==(1<<n)-1)ans=min(ans,sum);
for(int i=0;i<n;i++)
{
if((mask&(1<<i))==0)
{
long long dis=max(0ll,sp-en[i]);
sum+=dis;
f(mask|(1<<i),ex[i]);
sum-=dis;
}
}
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t)
{
n=s.size();
en=s;
ex=t;
f(0,1);
return ans;
}
# | 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... |