제출 #823951

#제출 시각아이디문제언어결과실행 시간메모리
823951vnm06Roller Coaster Railroad (IOI16_railroad)C++14
34 / 100
52 ms10596 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; int n; long long dp[200000][16]; long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { n = s.size(); int st2=(1<<n); for(int i=1; i<st2; i++) { int br1=0, pos=0; for(int j=0; j<n; j++) { if((1<<j)&i) {br1++; pos=j;} } if(br1==1) {dp[i][pos]=0; continue;} for(int j=0; j<n; j++) { dp[i][j]=1e18; if(!((1<<j)&i)) continue; for(int k=0; k<n; k++) { if(!((1<<k)&i) || k==j) continue; long long st=dp[i^(1<<j)][k]; if(s[j]<t[k]) st+=t[k]-s[j]; if(st<dp[i][j]) dp[i][j]=st; ///cout<<i<<" "<<j<<" "<<k<<" "<<" "<<s[j]<<" "<<t[j]<<" "<<s[k]<<" "<<t[k]<<endl; } } } long long mst=1e18; for(int i=0; i<n; i++) if(mst>dp[st2-1][i]) mst=dp[st2-1][i]; return mst; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...