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 <algorithm>
#include <vector>
#define INF 1E18
using namespace std;
int N;
long long int plan_roller_coaster(vector<int> s, vector<int> t) {
N = s.size();
if (N <= 8) {
vector<int> u;
for (int i = 0; i < 8; i++) {
u.push_back(i);
}
long long int ans = 0;
for (int i = 1; i < 8; i++) {
ans += max(0, t[u[i - 1]] - s[u[i]]);
}
while (next_permutation(u.begin(), u.end())) {
long long int temp = 0;
for (int i = 1; i < 8; i++) {
temp += max(0, t[u[i - 1]] - s[u[i]]);
}
ans = min(ans, temp);
}
return ans;
}
return 0;
}
# | 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... |