제출 #1037999

#제출 시각아이디문제언어결과실행 시간메모리
1037999vjudge1Roller Coaster Railroad (IOI16_railroad)C++17
34 / 100
46 ms8540 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; using lint=long long; lint plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); if(n<=16){ lint dp[1<<n][n]; for(int i=0;i<1<<n;i++){ for(int j=0;j<n;j++){ dp[i][j]=LLONG_MAX; } } for(int i=0;i<n;i++){ dp[1<<i][i]=0; } for(int mask=1;mask<1<<n;mask++){ for(int i=0;i<n;i++){ if((mask>>i)&1){ for(int j=0;j<n;j++){ if(!((mask>>j)&1)){ int to=mask|(1<<j); lint cost=t[i]-s[j]; if(cost<0)cost=0; if(dp[mask][i]+cost<dp[to][j]){ dp[to][j]=dp[mask][i]+cost; } } } } } } lint ans=LLONG_MAX; for(int i=0;i<n;i++){ if(dp[(1<<n)-1][i]<ans){ ans=dp[(1<<n)-1][i]; } } return ans; } 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...