Submission #28021

#TimeUsernameProblemLanguageResultExecution timeMemory
28021repeatingRoller Coaster Railroad (IOI16_railroad)C++11
34 / 100
126 ms15432 KiB
#include <bits/stdc++.h> #include "railroad.h" #define F first #define S second #define P push #define pb push_back #define MEM(dp,i) memset(dp,i,sizeof(dp)) #define W while #define R return #define C continue #define SI size() #define ll long long #define ld long double #define pll pair<ll,ll> #define pii pair<int,int> #define SF(x) scanf("%I64d",&x) #define SF2(x,y) scanf("%I64d%I64d",&x,&y) #define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z) #define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o) #define all(v) v.begin(),v.end() using namespace std; const long long INF = 1e15; const int MX=1000005; vector<int> s,e; int n; ll dp[17][(1<<16)+6]; ll DP(int x,int mask){ if(mask==(1<<n)-1)R 0; ll &ret=dp[x][mask]; if(ret!=-1)R ret; ret=INF; for(int i=0;i<n;i++){ if((1<<i)&mask)C; if(e[x]>s[i]){ ret=min(ret,DP(i,mask+(1<<i))+e[x]-s[i]); } else{ ret=min(ret,DP(i,mask+(1<<i))); } } R ret; } long long plan_roller_coaster(vector<int> s_, vector<int> t) { n=s_.SI; MEM(dp,-1); s=s_,e=t; ll ret=INF; for(int i=0;i<n;i++){ ret=min(ret,DP(i,(1<<i))); } R ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...