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();
if (n<=8){
vector<int> v;
for (int x = 0; x<n; x++){
v.push_back(x);
}
long long ans = 999999999999999;
long long curans = 0;
for (int x = 1; x<n; x++){
curans+=(t[x-1]>s[x])?(t[x-1]-s[x]):0;
}
ans = min(curans,ans);
while (next_permutation(v.begin(),v.end())){
long long curans = 0;
for (int x = 1; x<n; x++){
curans+=(t[v[x-1]]>s[v[x]])?(t[v[x-1]]-s[v[x]]):0;
}
ans = min(curans,ans);
}
return ans;
}
return 0;
}
# | 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... |