제출 #1069647

#제출 시각아이디문제언어결과실행 시간메모리
1069647IgnutRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
39 ms15188 KiB
// Ignut #include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e18 + 123; const int inf = 1e9 + 123; const int N = 16; ll dp[1 << N][N]; ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); for (int i = 0; i < 1 << n; i ++) for (int j = 0; j < n; j ++) dp[i][j] = INF; for (int i = 0; i < n; i ++) dp[1 << i][i] = 0; vector<pair<int, int>> lst; for (int mask = 1; mask + 1 < 1 << n; mask ++) { lst.push_back({__builtin_popcount(mask), mask}); } sort(lst.begin(), lst.end()); for (auto [popcnt, mask] : lst) { for (int i = 0; i < n; i ++) { if (!(mask & (1 << i))) continue; for (int j = 0; j < n; j ++) { if (mask & (1 << j)) continue; dp[mask | (1 << j)][j] = min(dp[mask | (1 << j)][j], dp[mask][i] + max(0, t[i] - s[j])); } } } ll res = INF; for (int i = 0; i < n; i ++) res = min(res, dp[(1 << n) - 1][i]); return res; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...