Submission #635347

#TimeUsernameProblemLanguageResultExecution timeMemory
635347shafinalamRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
52 ms13128 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; //#define int ll #include "railroad.h" ll dp[70005][25]; ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); for(int i=0;i<(1<<n);i++){ for(int j=0;j<n;j++){ dp[i][j] = 2e18; } } for(int i=1;i<(1<<n);i++){ int cnt=0; for(int j=0;j<n;j++){ if(i&(1<<j)){ cnt++; } } if(cnt==1){ for(int j=0;j<n;j++){ if(i&(1<<j)){ dp[i][j] = 0; } } continue; } for(int j=0;j<n;j++){ if(i&(1<<j)){ int p = i-(1<<j); for(int k=0;k<n;k++){ if(p&(1<<k)){ dp[i][j] = min(dp[i][j],dp[p][k]+max(0,t[k]-s[j])); } } } } } ll ans=2e18; for(int i=0;i<n;i++){ ans = min(ans,dp[(1<<n)-1][i]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...