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 pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
const ll INF = 1e17;
ll n, d;
long long plan_roller_coaster(vector<int> s, vector<int> t) {
n = s.size();
vector <pair <ll,ll> > arr;
arr.resize(n);
for (int i=0; i<n; i++) arr[i] = {(ll)s[i], (ll)t[i]};
sort(arr.begin(), arr.end());
d = INF;
do {
ll vel = arr[0].ss, currd = 0;
for (int i=1; i<n; i++) {
currd += max(0LL, vel-arr[i].ff);
vel = arr[i].ss;
}
d = min(currd, d);
} while (next_permutation(arr.begin(), arr.end()));
return d;
}
# | 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... |