Submission #798750

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