Submission #121181

#TimeUsernameProblemLanguageResultExecution timeMemory
121181PlurmRoller Coaster Railroad (IOI16_railroad)C++11
34 / 100
67 ms8668 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; long long dp[65536][16]; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int) s.size(); for(int i = 0; i < (1 << n); i++){ for(int j = 0; j < n; j++){ dp[i][j] = 1e18; } } for(int i = 0; i < n; i++){ dp[1 << i][i] = 0; } for(int i = 0; i < (1 << n); i++){ for(int j = 0; j < n; j++){ if(i & (1 << j)) for(int k = 0; k < n; k++){ if(i & (1 << k)) continue; dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + max(t[j], s[k]) - s[k]); } } } long long ans = 1e18; for(int i = 0; i < n; i++){ ans = min(ans, dp[(1 << n)-1][i]); } 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...