# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410833 | EJOI2019Andrew | 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"
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
using namespace std;
long long plan_roller_coaster(vector<int> s,vector<int> t) {
int n=(int)s.size();
ll res=1e18;
vi a;
for(int i=0;i<n;i++)
a.pb(i);
do{
ll G=0,c=0;
for(int i=0;i<n;i++)
{
if(c>s[a[i]])
G+=(c-s[a[i]]);
}
c=t[a[i]];
res=min(res,G);
}while(next_permutation(a.begin(),a.end()));
return res;
}