이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[16][1<<16];
ll plan_roller_coaster(vector<int> s, vector<int> t) {
int n = (int) s.size();
if(n > 16) return 42;
for(int i = 0; i < n; i++) fill(dp[i], dp[i] + (1 << n), LLONG_MAX);
for(int i = 0; i < n; i++) dp[i][1<<i] = 0;
for(int b = 1; b < (1 << n); b++){
for(int i = 0; i < n; i++){
if(!(b >> i & 1)) continue;
for(int j = 0; j < n; j++){
if(b >> j & 1) continue;
ll &d = dp[j][b | (1 << j)];
d = min(d, dp[i][b] + max(0, t[i]-s[j]));
}
}
}
ll ans = LLONG_MAX;
for(int i = 0; i < n; i++){
ans = min(ans, dp[i][(1<<n)-1]);
}
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... |