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 deb(x) cerr << #x <<": " << x << '\n';
using namespace std;
typedef long long ll;
const int INF = 1e9 + 1;
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
int n = (int) s.size();
vector<int> p;
for(int i = 0; i < n; ++i)
p.push_back(i);
ll ans = INF;
do{
ll res = 0;
for(ll i = 0; i < n-1; ++i){
res += ( (t[p[i]] - s[p[i+1]]) < 0 ? 0 : t[p[i]] - s[p[i+1]]);
}
ans = min(ans, res);
} while(next_permutation(p.begin(),p.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... |