Submission #940854

#TimeUsernameProblemLanguageResultExecution timeMemory
940854LalicRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
35 ms10572 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define mp make_pair typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5+10; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9+7; ll dp[16][65540]; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n=(int)s.size(); for(int i=0;i<n;i++) for(int j=0;j<(1<<n);j++) dp[i][j]=LINF; dp[0][0]=0; for(int i=1;i<(1<<n);i++){ for(int j=0;j<n;j++){ if(!(i&(1<<j))) continue; int curr=(i^(1<<j)); if(curr==0) dp[j][i]=0; else{ for(int k=0;k<n;k++){ if(!(curr&(1<<k))) continue; dp[j][i]=min(dp[j][i], dp[k][curr]+max((ll)t[k]-(ll)s[j], 0ll)); } } } } ll ans=LINF; for(int i=0;i<n;i++) ans=min(ans, dp[i][(1<<n)-1]); 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...