Submission #595043

#TimeUsernameProblemLanguageResultExecution timeMemory
595043LucppRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
53 ms14004 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int)s.size(); vector<vector<ll>> dp(1<<n, vector<ll>(n)); for(int msk=1; msk < (1<<n); msk++){ if(__builtin_popcount(msk) == 1) continue; for(int i = 0; i < n; i++){ if(!(msk & (1<<i))) continue; dp[msk][i] = INF; int m = msk^(1<<i); for(int j = 0; j < n; j++){ if(!(m & (1<<j))) continue; dp[msk][i] = min(dp[msk][i], dp[m][j] + max(0, t[j]-s[i])); } } } ll ans = INF; 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...