Submission #937146

#TimeUsernameProblemLanguageResultExecution timeMemory
937146ThegeekKnight16Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
41 ms13904 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; typedef long long ll; const ll INF = 0x3f3f3f3f3f3f3f3f; ll plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int N = s.size(); vector<vector<ll>> dp((1 << N), vector<ll>(N)); for (int mask = 1; mask < (1 << N); mask++) { if (__builtin_popcount(mask) == 1) continue; for (int v = 0; v < N; v++) { if (!(mask & (1 << v))) continue; dp[mask][v] = INF; for (int v2 = 0; v2 < N; v2++) { if (v2 == v || !(mask & (1 << v2))) continue; dp[mask][v] = min(dp[mask][v], dp[mask-(1 << v)][v2] + max(0LL, (ll)t[v2] - (ll)s[v])); } } } return *min_element(dp.back().begin(), dp.back().end()); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...