# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100054 | helloworldworld | Roller Coaster Railroad (IOI16_railroad) | C++14 | 0 ms | 0 KiB |
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"
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
int arr[n];
for(int i=0;i<n;i++)
arr[i]=i;
long long mini,cur;
for(int i=1;i<n;i++){
if(t[i-1]>s[i])
cur+=t[i-1]-s[i];
}
mini=cur;
while(next_permutation(arr,arr+n)){
for(int i=1;i<n;i++){
if(t[i-1]>s[i])
cur+=t[i-1]-s[i];
}
if(mini>cur) mini=cur;
}
return mini;
}