Submission #256307

#TimeUsernameProblemLanguageResultExecution timeMemory
256307tinjyuRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
137 ms18040 KiB
#include "railroad.h" #include <iostream> using namespace std; long long int n,dp[20][100005][2],bit[1005],tag[10005]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n = (int) s.size(); bit[0]=1; for(int i=1;i<=20;i++)bit[i]=bit[i-1]*2; for(int i=0;i<=70000;i++) { for(int j=0;j<n;j++) { dp[j][i][0]=9999999999999; dp[j][i][1]=9999999999999; } } for(int i=0;i<n;i++) { dp[i][bit[i]][0]=0; } for(int i=1;i<n;i++) { for(int j=0;j<=70000;j++) { for(int k=0;k<n;k++) { dp[k][j][i%2]=9999999999999; } } for(int j=0;j<n;j++) { for(int k=0;k<=70000;k++) { if(dp[j][k][(i-1)%2]==9999999999999)continue; for(int l=0;l<n;l++) { if((bit[l] & k)==0) { dp[l][k+bit[l]][i%2]=min(dp[l][k+bit[l]][i%2],dp[j][k][(i-1)%2]+max(0,t[j]-s[l])); } } } } for(int j=0;j<n;j++) { for(int k=0;k<=10000;k++) { if(dp[j][k][i%2]!=9999999999999) { //cout<<j<<" "<<k<<" "<<dp[j][k][i%2]<<endl; } } } } long long int ans=9999999999999; for(int i=0;i<n;i++) { ans=min(dp[i][bit[n]-1][(n-1)%2],ans); } 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...