Submission #42709

#TimeUsernameProblemLanguageResultExecution timeMemory
42709funcsrRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
95 ms14240 KiB
#include "railroad.h" #include <iostream> #include <vector> #include <algorithm> #include <cassert> using namespace std; #define rep(i, n) for (int i=0; i<(n); i++) #define INF (1LL<<60) int N; int S[200000], T[200000]; long long dp[1<<16][16]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { N = s.size(); rep(i, N) S[i] = s[i], T[i] = t[i]; assert(N <= 16); rep(i, 1<<N) rep(j, N) dp[i][j] = INF; rep(i, N) dp[1<<i][i] = 0; rep(b, 1<<N) { rep(last, N) { if (dp[b][last] == INF) continue; rep(t, N) if (((b>>t)&1) == 0) { dp[b|(1<<t)][t] = min(dp[b|(1<<t)][t], dp[b][last] + max(T[last]-S[t], 0)); } } } long long m = INF; rep(i, N) m = min(m, dp[(1<<N)-1][i]); return m; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...