이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |