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<bits/stdc++.h>
#include "railroad.h"
using namespace std;
//#define int long long;
vector<vector<int > > per(int n){
if(n==1){
return {{0}};
}
vector<vector<int> > ans;
vector<vector<int> > u=per(n-1);
for(auto e: u){
vector<int> neu(n);
for(int i=0; i<n; i++){
neu[i]=n-1;
for(int j=i+1; j<n; j++){
neu[j]=e[j-1];
}
ans.push_back(neu);
neu[i]=e[i];
}
}
return ans;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<vector<int> > pos=per(n);
long long best=1e18;
for(auto e: pos){
long long ans=0;
for(int i=0; i<n-1; i++){
int j=e[i];
if(s[j+1]<t[j]){
ans+=(long long)t[j]-(long long)s[j+1];
}
}
best=min(best, ans);
}
return best;
}
/*signed main(){
}*/
# | 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... |