Submission #121140

#TimeUsernameProblemLanguageResultExecution timeMemory
121140win11905Roller Coaster Railroad (IOI16_railroad)C++11
34 / 100
141 ms26264 KiB
#include "railroad.h" #include <bits/stdc++.h> #define long long long using namespace std; const int N = 16; int n; vector<int> s, t; long dp[N][1<<N]; long solve(int u, int bit) { if(dp[u][bit] != -1) return dp[u][bit]; if((bit ^ (1 << u)) == 0) return dp[u][bit] = 0; dp[u][bit] = 1e18; for(int i = 0; i < n; ++i) if(i != u && ((bit >> i) & 1)) { long val = (t[i] > s[u] ? (t[i] - s[u]) : 0) + solve(i, bit ^ (1 << u)); dp[u][bit] = min(dp[u][bit], val); } return dp[u][bit]; } long plan_roller_coaster(vector<int> s, vector<int> t) { n = (int)s.size(); ::s = s, ::t = t; memset(dp, -1, sizeof dp); int bit = (1 << n) - 1; long ans = 1e18; for(int i = 0; i < n; ++i) ans = min(ans, solve(i, bit)); return ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...