Submission #607502

#TimeUsernameProblemLanguageResultExecution timeMemory
607502skittles1412Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
241 ms524288 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \ dbgh(__VA_ARGS__); #else #define dbg(...) #define cerr \ if (false) \ cerr #endif using ll = long long; #define endl "\n" #define long int64_t #define sz(x) int((x).size()) ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = sz(s); long dp[1 << n][n]; memset(dp, 0x3f, sizeof(dp)); for (int i = (1 << n) - 1; i >= 0; i--) { for (int j = 0; j < n; j++) { if ((i >> j) & 1) { continue; } else if ((i | (1 << j)) == (1 << n) - 1) { dp[i][j] = 0; continue; } for (int k = 0; k < n; k++) { if (j != k && !((i >> k) & 1)) { dp[i][j] = min(dp[i][j], dp[i | (1 << j)][k] + max(0, t[j] - s[k])); } } } } return *min_element(dp[0], dp[0] + 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...