Submission #530744

#TimeUsernameProblemLanguageResultExecution timeMemory
530744CyanmondRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
46 ms13876 KiB
#include <bits/stdc++.h> using i64 = long long; template <typename T> using Vec = std::vector<T>; constexpr i64 inf64 = 2000000000000000000; template <typename T> bool setmin(T &a, const T v) { if (a > v) { a = v; return true; } return false; } long long plan_roller_coaster(std::vector<int> S, std::vector<int> T) { const int N = (int)S.size(); Vec<Vec<i64>> dp(1 << N, Vec<i64>(N, inf64)); for (int i = 0; i < N; ++i) dp[1 << i][i] = 0; for (int bit = 0; bit < (1 << N); ++bit) { for (int last = 0; last < N; ++last) { if (not(bit & (1 << last))) continue; for (int next = 0; next < N; ++next) { if (bit & (1 << next)) continue; setmin(dp[bit | (1 << next)][next], dp[bit][last] + std::max(0, T[last] - S[next])); } } } i64 answer = inf64; for (int i = 0; i < N; ++i) setmin(answer, dp[(1 << N) - 1][i]); return (long long)answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...