Submission #137419

#TimeUsernameProblemLanguageResultExecution timeMemory
137419HassoonyRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
120 ms45984 KiB
#include <bits/stdc++.h> #include "railroad.h" //#include "grader.cpp" using namespace std; typedef long long ll; const ll inf=(1ll<<61); const int MX=17; ll dp[(1<<MX)][MX],S[MX],T[MX]; int n; ll DP(ll mask,ll last){ if(mask+1==(1<<n))return 0; ll &ret=dp[mask][last];if(ret!=-1)return ret; ret=inf; for(int i=0;i<n;i++){ if(mask&(1<<i))continue; if(last==n){ ret=min(ret,DP(mask|(1<<i) , i)); } else { ret=min(ret,DP(mask|(1<<i) , i) + max(0ll,T[last] - S[i])); } } return ret; } ll plan_roller_coaster(vector<int> s, vector<int> t) { n = (int) s.size(); for(int i=0;i<n;i++)S[i]=s[i],T[i]=t[i]; memset(dp,-1,sizeof(dp)); return DP(0,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...