Submission #933832

#TimeUsernameProblemLanguageResultExecution timeMemory
9338321075508020060209tcRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
39 ms11100 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; #define ll long long ll lowbit(int x){return x&-x;} ll dp[(1<<17)][20]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); for(int i=1;i<(1<<n);i++){ for(int j=0;j<n;j++){ dp[i][j]=1e16; if( ((i&(1<<j))==0)){continue;} if(__builtin_popcount(i)==1){ dp[i][j]=0; continue; } for(int k=0;k<n;k++){ if( !(i&(1<<k)) ){continue;} if(k==j){continue;} ll cst=dp[i^(1<<j)][k]+max(0,t[k]-s[j]); dp[i][j]=min(dp[i][j],cst); } } } long long ret=dp[(1<<n)-1][0]; for(int j=0;j<n;j++){ ret=min(ret,dp[(1<<n)-1][j]); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...