Submission #408675

#TimeUsernameProblemLanguageResultExecution timeMemory
408675sadRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
100 ms43972 KiB
#include<bits/stdc++.h> #include "railroad.h" #define ll long long #define fi first #define se second #define pb push_back using namespace std; int n;const int M=100000; int S[20],T[20]; ll dp[M][21]; ll go(int x,int y) { if(x>n-1)return 0; ll z=0; if(T[x]<=S[y])return 0; z=T[x]-S[y];return z; } ll d(int x,int mask,int last) { if(x==n)return 0; ll &u=dp[mask][last]; if(u!=-1)return u; u=1e17;ll one=1; for(int i=0;i<n;i++) { ll w=(one<<i); if((mask&w)>0)continue; ll z=go(last,i); u=min(u,d(x+1,mask+w,i)+z); } return u; } long long plan_roller_coaster(vector<int> s,vector<int> t) { memset(dp,-1,sizeof dp); n = (int) s.size(); for(int i=0;i<n;i++) { S[i]=s[i]; T[i]=t[i]; } ll x=d(0,0,n+2); return x; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...