This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
ll plan_roller_coaster(vector<int> s,vector<int> t){
int n=s.size(),m;
int pwr[17];
for(int i=pwr[0]=1;i<17;i++)
pwr[i]=pwr[i-1]*2;
ll dp[pwr[n]][n];
for(int i=1;i<pwr[n];i++)
for(int j=0;j<n;j++)
dp[i][j]=1e17;
for(int i=1;i<pwr[n];i++){
for(int j=0;j<n;j++){
if((i&pwr[j])==0) continue;
m=i-pwr[j];
if(!m) dp[i][j]=0;
else{
for(int k=0;k<n;k++)
if((m&pwr[k])==pwr[k])
dp[i][j]=min(dp[i][j],dp[m][k]+max(0,t[k]-s[j]));
}
}
}
ll x=1e17;
for(int i=0;i<n;i++)
x=min(x,dp[pwr[n]-1][i]);
return x;
}
# | 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... |