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;
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
pii a[200100];
long long plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
vector<int> q;
for(int i=1; i<=n; i++){
a[i] = {t[i-1], s[i-1]};
q.pb(i);
}
ll ans = 1e18;
do{
ll res = 0;
for(int i=1; i<n; i++){
pii x = a[q[i-1]], y = a[q[i]];
res += max(x.ff - y.ss, 0);
}
ans = min(ans, res);
}while(next_permutation(q.begin(), q.end()));
return ans;
}
# | 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... |