Submission #135799

#TimeUsernameProblemLanguageResultExecution timeMemory
135799Runtime_error_Roller Coaster Railroad (IOI16_railroad)C++14
34 / 100
104 ms17912 KiB
#include "railroad.h" #include <bits/stdc++.h> #define ll long long using namespace std; const ll inf = 17 , MX = 1e18+9; ll n,s[inf],t[inf],dp[(1<<inf)][inf]; ll solve(ll mask,ll cur){ if(mask == (1ll<<n)-1ll) return 0; ll &ret = dp[mask][cur]; if(ret != -1) return ret; ret = MX; for(int i=0;i<n;i++) if(!(mask & (1ll<<i) ) ) ret = min(ret , solve( mask | (1ll<<i) , i ) + max( 0ll , t[cur] - s[i] ) ); return ret; } long long plan_roller_coaster(vector<int> S, vector<int> T) { ll ans = MX; n = (ll) S.size(); for(ll i=0;i<n;i++) s[i] = S[i],t[i] = T[i]; memset(dp,-1,sizeof(dp)); for(int i=0;i<n;i++) ans = min( ans , solve((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...