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<int> arr(n,0);
long long min=0;
for(int i=0;i<n;i++)
{
arr[i]=i;
if(i>0 && s[arr[i]]<t[arr[i-1]])
{
min=min-s[arr[i]]+t[arr[i-1]];
}
}
do
{
long long tempmin=0;
for(int i=0;i<n;i++)
{
if(i>0 && s[arr[i]]<t[arr[i-1]])
{
tempmin=tempmin-s[arr[i]]+t[arr[i-1]];
}
}
if(tempmin<min)
{
min=tempmin;
}
} while (next_permutation(arr.begin(),arr.end()));
return min;
}
# | 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... |