제출 #574474

#제출 시각아이디문제언어결과실행 시간메모리
574474EliasRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
45 ms10060 KiB
#include <bits/stdc++.h> #ifndef _DEBUG #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include "railroad.h" #endif using namespace std; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); vector<vector<int64_t>> dp((1 << n) + 1, vector<int64_t>(n, INT32_MAX)); dp[0][0] = 0; for (int i = 0; i < n; i++) { dp[1 << i][i] = 0; } for (int bits = 1; bits < (1 << n) + 1; bits++) for (int i = 0; i < n; i++) { if (!(bits & (1 << i))) continue; for (int j = 0; j < n; j++) { if (i == j || !(bits & (1 << j))) continue; dp[bits][i] = min(dp[bits][i], dp[bits ^ (1 << i)][j] + max(t[j] - s[i], 0)); } } return *min_element(dp[(1 << n) - 1].begin(), dp[(1 << n) - 1].end()); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...