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"
#define fi first
#define se second
#define ll long long
using namespace std;
const ll inf = (1LL << 60);
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = s.size();
vector <int> v;
for(int i = 0; i < n; i++){
v.push_back(i);
}
ll ans = inf;
do{
ll sum = 0;
for(int i = 0; i < n - 1; i++){
sum += max(0, t[v[i]] - s[v[i + 1]]);
// cout << i << ' ' << t[v[i]] << ' ' << s[v[i + 1]] << endl;
}
// for(int i = 0; i < n; i++){
// cout << v[i];
// }
// cout << ' ' << sum << endl;
ans = min(ans, sum);
}while(next_permutation(v.begin(), v.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... |