Submission #1034919

#TimeUsernameProblemLanguageResultExecution timeMemory
1034919aymanrsRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
265 ms524288 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = s.size(); long long dp[1<<n][n]; for(int i = 0;i < n;i++) dp[(1<<n)-1][i] = 0; for(int b = (1<<n)-2;b;b--){ for(int j = 0;j < n;j++){ if(!((b>>j)&1)) continue; dp[b][j] = LONG_LONG_MAX; for(int k = 0;k < n;k++){ if((b>>k)&1) continue; dp[b][j] = min(dp[b][j], dp[b|(1<<k)][k]+max(0, t[j]-s[k])); } } } long long ans = LONG_LONG_MAX; for(int i = 0;i < n;i++) ans = min(ans, dp[1<<i][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...