Submission #423527

#TimeUsernameProblemLanguageResultExecution timeMemory
423527vanicRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
55 ms8996 KiB
#include "railroad.h" #include <algorithm> #include <cmath> #include <vector> #include <iostream> using namespace std; typedef long long ll; const int maxn=17; const ll inf=1e18; int n; ll dp[(1<<maxn)][maxn]; ll plan_roller_coaster(vector < int > s, vector < int > t){ n=s.size(); int x; for(int i=1; i<(1<<n); i++){ for(int j=0; j<n; j++){ if(i&(1<<j)){ dp[i][j]=inf; x=i^(1<<j); if(!x){ dp[i][j]=0; } for(int k=0; k<n; k++){ if(x&(1<<k)){ dp[i][j]=min(dp[i][j], dp[x][k]+max(0, t[k]-s[j])); } } } } } ll mini=inf; for(int i=0; i<n; i++){ mini=min(mini, dp[(1<<n)-1][i]); } return mini; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...