Submission #64861

#TimeUsernameProblemLanguageResultExecution timeMemory
64861yogahmadRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
243 ms13604 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define fbo find_by_order #define ook order_of_key #define f first #define s second #define pb push_back #define reset(a,b) memset(a,b,sizeof a); #define MOD 1000000007 #define MID (l+r)/2 #define ALL(x) x.begin(),x.end() #define debug(x) cout<<#x<<" = "<<(x)<<endl #define mx 100003 #define pc(x) putchar_unlocked(x); int n; long long dep[18][(1<<16)+10]; vector<int>S,T; long long dp(int now,int mask){ if(__builtin_popcount(mask)==n)return 0; long long&ret=dep[now][mask]; if(ret!=-1)return ret; ret=1e18; for(int i=0;i<n;i++){ if(!(mask&(1<<i))){ long long cost=0; if(T[now]>=S[i])cost=T[now]-S[i]; int nex=mask|(1<<i); ret=min(ret,dp(i,nex)+cost); } } return ret; } long long plan_roller_coaster(vector<int> s, vector<int> t) { n=s.size(); t.pb(1); S=s; T=t; if(n<=16){ reset(dep,-1); return dp(n,0); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...