제출 #636822

#제출 시각아이디문제언어결과실행 시간메모리
636822tabrRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
48 ms13876 KiB
#include <bits/stdc++.h> using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int) s.size(); const long long inf = (long long) 1e18; 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 mask = 1; mask < (1 << n); mask++) { for (int i = 0; i < n; i++) { if (~mask & (1 << i)) { continue; } for (int j = 0; j < n; j++) { if (mask & (1 << j)) { continue; } int nmask = mask | (1 << j); dp[nmask][j] = min(dp[nmask][j], dp[mask][i] + max(0, t[i] - s[j])); } } } return *min_element(dp.back().begin(), dp.back().end()); } #ifdef tabr int main() { ios::sync_with_stdio(false); cin.tie(0); debug(plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6})); return 0; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...