Submission #108214

#TimeUsernameProblemLanguageResultExecution timeMemory
108214tictaccatRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
142 ms11256 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); vector<vector<ll>> dp((1 << n), vector<ll>(n+1, INF)); for (int j = 0; j < n; j++) dp[(1<<j)][j] = 0; ll low = INF; for (int i = 2; i <= n; i++) { for (int bits = 0; bits < (1 << n); bits++) { if (__builtin_popcount(bits) != i) continue; for (int j = 0; j < n; j++) { if (!(bits & (1<<j))) continue; for (int k = 0; k < n; k++) { if (k == j || !(bits&(1<<k))) continue; dp[bits][j] = min(dp[bits][j], dp[bits^(1<<j)][k] + max(0,t[k]-s[j])); } if (i == n) low = min(low,dp[bits][j]); } } } return low; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...