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;
typedef long long un;
typedef vector<un> vuc;
#define REP(i, a, b) for(un i = a; i < b; i++)
#define FEAC(i, a) for (auto&& i : a)
#define vec vector
#define ALL(x) (x).begin(), (x).end()
constexpr un INF = INT64_MAX;
un compute(vec<int> s, vec<int> t, un N, vuc perm){
un ret = 0;
REP(i, 0, N-1){
ret += max(0, t[perm[i]] - s[perm[i+1]]);
}
return ret;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
un N = (un) s.size();
if (N > 8) return 0;
vuc perm(N);
iota(ALL(perm), 0);
un ret = INF;
do{
ret = min(ret, compute(s, t, N, perm));
} while(next_permutation(ALL(perm)));
return ret;
}
# | 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... |