Submission #425826

#TimeUsernameProblemLanguageResultExecution timeMemory
425826temurbek_khujaevRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
58 ms10572 KiB
#include "railroad.h" #include <bits/stdc++.h> const int N = 16; long long INF = 1e16; long long dp[1 << N][N]; using namespace std; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); for (int mask = 1; mask < (1 << n); mask++) { for (int i = 0; i < n; i++) { dp[mask][i] = INF; if ((mask & (1 << i)) == 0) continue; int p_mask = (mask ^ (1 << i)); if (p_mask == 0) dp[mask][i] = 0; for (int j = 0; j < n; j++) { if (p_mask & (1 << j)) { dp[mask][i] = min(dp[mask][i], dp[p_mask][j] + 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...