Submission #134692

#TimeUsernameProblemLanguageResultExecution timeMemory
134692ckodserRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
92 ms10788 KiB
#include "railroad.h" #include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define pii pair<ll,ll> #define F first #define S second #define ld long double using namespace :: std; const ll maxn=17; const ll inf=1e17+900; ll ger[maxn][maxn]; ll dp[1<<maxn][maxn]; long long plan_roller_coaster(vector<int> s,vector<int> t) { int n = (int) s.size(); for(ll i=0;i<n;i++){ for(ll j=0;j<n;j++){ ger[i][j]=max(0,t[i]-s[j]); } } for(ll i=1;i<(1<<n);i++){ for(ll j=0;j<n;j++){ if(i!=(1<<j)){ if((i>>j)&1){ dp[i][j]=inf; for(ll k=0;k<n;k++){ if(((i>>k)&1) && k!=j){ dp[i][j]=min(dp[i][j],dp[i^(1<<j)][k]+ger[j][k]); } } } } } } ll ans=inf; for(ll i=0;i<n;i++){ ans=min(ans,dp[(1<<n)-1][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...