Submission #758878

#TimeUsernameProblemLanguageResultExecution timeMemory
758878Dan4LifeRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
38 ms10696 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; using ll = long long; const ll LINF = (ll)2e18; ll dp[1<<16][16]; ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int)s.size(); for(int i = 0; i < (1<<n); i++) for(int j = 0; j < n; j++) dp[i][j]=LINF; for(int i = 0; i < n; i++) dp[1<<i][i]=0; for(int mask = 1; mask < (1<<n); mask++){ for(int i = 0; i < n; i++) if((mask>>i)&1) for(int j = 0; j < n; j++) if((mask>>j)&1 and j!=i) dp[mask][i] = min(dp[mask][i], dp[mask^(1<<i)][j]+(ll)max(0,t[j]-s[i])); } return *min_element(dp[(1<<n)-1],dp[(1<<n)-1]+n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...