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 "grader.cpp"
using namespace std;
const long long inf = 1e18 + 5;
int n;
vector <int> s, t;
long long memo[(1<<17)+5][20];
long long rec(int used, int usedCnt, int last)
{
if(usedCnt==n) return 0;
long long answer = inf;
for(int nxt = 0;nxt<n;nxt++)
{
if(((used>>nxt)&1)==1) continue;
answer = min(answer, rec(used+(1<<nxt), usedCnt+1, nxt) + max(0, t[last]-s[nxt]));
}
return answer;
}
long long plan_roller_coaster(vector<int> _s, vector<int> _t)
{
s = _s;
t = _t;
n = s.size();
long long answer = inf;
for(int first = 0;first<n;first++) answer = min(answer, rec((1<<first), 1, first));
return answer;
}
# | 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... |