Submission #66307

#TimeUsernameProblemLanguageResultExecution timeMemory
66307mirbek01Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
84 ms17292 KiB
# include "railroad.h" # include <bits/stdc++.h> using namespace std; const int N = (1 << 17); long long dp[17][N]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); for(int i = 1; i < N; i ++) for(int j = 0; j < n; j ++) dp[j][i] = 1e18; for(int i = 0; i < n; i ++){ dp[i][1 << i] = 0; } for(int mask = 1; mask < (1 << n); mask ++){ for(int i = 0; i < n; i ++){ if(mask & (1 << i)) continue; int to = mask + (1 << i); for(int j = 0; j < n; j ++){ if(!(mask & (1 << j))) continue; dp[i][to] = min(dp[i][to], dp[j][mask] + max(t[j] - s[i], 0)); } } } long long ans = 1e18; for(int i = 0; i < n; i ++) ans = min(ans, dp[i][(1 << n) - 1]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...