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>
using namespace std;
const long long INF = 1e18;
long long plan_roller_coaster(vector<int> s, vector<int> t){
int n = (int)s.size();
vector<int> next(n);
for(int i = 0; i < n; ++i)
next[i] = i;
// next vector is sorted
long long answer = INF;
do{
long long sum = 0;
for(int i = 1; i < n; ++i)
sum += max(0, t[next[i-1]]-s[next[i]]);
answer = min(answer, sum);
}while(next_permutation(next.begin(), next.end()));
return answer;
}
// int main(){
// long long jogap = plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6});
// printf("%lld", jogap);
// }
# | 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... |