Submission #206346

#TimeUsernameProblemLanguageResultExecution timeMemory
206346autumn_eelRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
80 ms8572 KiB
#include "railroad.h" #include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; typedef long long ll; const ll INF=0x3f3f3f3f3f3f3f3f; ll dp[1<<16][16]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); assert(n<=16); memset(dp,0x3f,sizeof(dp)); rep(i,n){ dp[1<<i][i]=0; } rep(i,1<<n)rep(j,n){ if(dp[i][j]==INF)continue; rep(k,n){ if(i>>k&1)continue; ll cost=dp[i][j]+max(0,t[j]-s[k]); dp[i|1<<k][k]=min(dp[i|1<<k][k],cost); } } return *min_element(dp[(1<<n)-1],dp[(1<<n)-1]+n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...