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>
#define ent '\n'
typedef long long ll;
using namespace std;
const int maxn = 2e5+12;
ll dp[1 << 17][20];
int n;
long long plan_roller_coaster(vector<int> s, vector<int> t){
n = s.size();
for(int mask=1;mask<(1 << n);mask++){
for(int v=0;v<n;v++){
if(!(mask & (1 << v))){
continue;
}
dp[mask][v] = 1e18;
if((1 << v) == mask){
dp[mask][v] = 0;
}
for(int to=0;to<n;to++){
if(!(mask & (1 << to)) || v == to){
continue;
}
dp[mask][v] = min(dp[mask][v], dp[mask - (1 << v)][to] + max(0, t[to] - s[v]));
}
}
}
ll ans = 1e18;
for(int i=0;i<n;i++){
ans = min(ans, dp[(1 << n) - 1][i]);
}
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... |